标签:
#include <stdio.h> main() { int yea,k,i,j; printf("您想要哪一年的日历:"); scanf("%d",&yea); printf("\n\n"); printf("%d年的日历为:\n",yea); k=(yea+(yea-1)/4-(yea-1)/100+(yea-1)/400)%7; int c[12]={31,28,31,30,31,30,31,31,30,31,30,31}; int temp=0; if(yea%4==0&&yea%400==0||yea%100!=0) c[1]=29; else c[1]=28; for(i=0;i<12;i++) { printf("%d MONTH\n",i+1); printf(" Sun Mon Tue Wed Thu Fri Sat\n"); for(j=1;j<=k;j++) { temp++; printf(" "); } for(j=1;j<=c[i];j++) { temp++; printf("%4d",j); if(temp%7==0) printf("\n"); } printf("\n"); k=(k+j-1)%7; } }
标签:
原文地址:http://www.cnblogs.com/zhanghuanqiao/p/4989578.html