z=getchar();
if(z=='y'||z=='Y') //判断是 rili(); // 调用函数 if(z=='n'||z=='N') // 判断不是结束 getchar(); return 0; }
void print(int year,int month) //print函数的定义 {
int i,j,n,leap,days,k,count;
leap=dobb(year); //函数调用及赋值 days=date1(year,month-1,1); //printf(\年\\n\
for(i=month-1;i<=month+1;i++) //输出上下月的情况 {if(i<1) printf(\月份\\n\ // 上年的12月 if(i>12) printf(\月份\\n\ // 下年的1月 if(i>0&&i<13) printf(\月份\\n\ //本年的月份 printf(\ printf(\
printf(\日\一\二\三\四\五\六\ 输出格式
if(days==7) //控制输出的个数 {
days=0; }
else n=days; printf(\
for(j=1;j<=8*days;j++) //控制输出的日期对齐 printf(\ switch(i) {
case 0: case 1: case 3: case 5: case 7: case 8: case 10:
case 12:count=31;break; case 4: case 6:
case 9:
case 11:count=30;break;
case 2:if(leap)count=29; //2月不同情况的判断 else count=28; break; }
for(k=1;k<=count;k++) // 逐渐输出每月的日期 {
printf(\ n++; if(n==7)
{printf(\ }printf(\ days=n; } }
int dobb(int year) //判断年份的类型函数的定义 {
if(date.year%4==0&&date.year0!=0||(date.year@0==0)) return(1); //闰年输出1 else return(0); //平年输出0 }
int date1(int year,int month,int day) //date1函数的定义 {int leap,cn=0,sum;
leap=dobb(year); // 调用函数 switch(month-1) {
case 11:+=30; case 10:+=31; case 9:+=30; case 8:+=31; case 7:+=31; case 6:+=30; case 5:+=31; case 4:+=30; case 3:+=31;
case 2: if(leap)cn+=29; else+=28;
case 1:+=31; default:cn+=day; }
sum=year-1+(year-1)/4-(year-1)/100+(year-1)/400+cn; return(sum%7); //判断星期几 }
C语言课程设计报告 - 万年历1



