用C语言写的万年历代码

时间:2015-04-27 07:01:31
【文件属性】:
文件名称:用C语言写的万年历代码
文件大小:978B
文件格式:CPP
更新时间:2015-04-27 07:01:31
万年历代码 #include int main() { int i,month,k,days,year,weekday=1; printf("input year:"); scanf("%d",&year;); printf("日\t一\t二\t三\t四\t五\t六\n"); for(month=1;month<=12;month++) { switch(month) { case 4: case 6: case 9: case 11: days=30; break; case 2: if((year%4==0&&year0;)||year@0==0) days=29; else days=28; break; case 1: case 3: case 5: case 7: case 8: case 10: case 12: days=31; break; } printf("\n\n%d月\n",month); for(k=1;k<=weekday;k++) { printf("\t"); } for(i=1;i<=days;i++) { printf("%d\t",i); if((i+weekday)%7==0) { printf("\n"); } } weekday=(days+weekday)%7; } return 0; }

网友评论