c语言编写一万年历系统

2024-12-17 13:24:54
推荐回答(3个)
回答1:

C语言版本的已经发往你的邮箱,请查收

 

现已更新好,去除农历信息

回答2:

没有用C写过,上面是C++BUilder写的

 

上面的C++写的

回答3:

#include
#include

int*daysandweek(int*y,int*week);
bool runnian(int*);

void main()
{
struct tm *local;
time_t t;
t=time(0);
local=localtime(&t);
printf("日历---冰之龙制作\n");

int year,*y;
int *week,p=1;
week=&p;
int monthday[]={31,28,31,30,31,30,31,31,30,31,30,31};
char month[12][12]={"January","February","March","April","May","June","July","August","September","October","November","December"};
char weekday[7][4]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};

year=local->tm_year;year+=1900;
printf("%d年%d月\n",year,local->tm_mon+1);
printf("\n");
y=&year;
if(runnian(y))
monthday[1]=29;
daysandweek(y,week);
for(int j=0;j<=11;j++)
{if(j==local->tm_mon){
for(int k=0;k<15;k++)
printf(" "); printf("%s\n",month[j]);
printf("_____________________________________\n");
for(int g=0;g<=6;g++)
printf("%s ",weekday[g]);
printf("\n");
for(int x=1;x<=*week;x++)
for( k=0;k<5;k++)
printf(" ");
for(int m=1;m<=monthday[j];m++)
{
if((*week+m)%7==0)
printf("%d\n",m);
else
if(m<10)
printf("%d ",m);
else
printf("%d ",m);
}
printf("\n\n\n");

}
*week=(*week+monthday[j])%7;
}

}

bool runnian(int* y)
{
int*t=y;
if(*t%4==0&&*t%100!=0||*t%100==0&&*t%400==0)
return true;
else
return false;
}
int*daysandweek(int*y,int*week)
{
int days=1,*z;
for(int i=1;i<*y;i++)
{
z=&i;
days+=365;
if(runnian(z))
days++;
}

*week=days%7;
return week;
}