输出日历函数出错
要求编写程序,输出任意年份的日历,两列排列#include <stdio.h>
void main ()
{
int y,num,s1,s2,w1,w2,w,d1,d2,m1,m2;
printf ("请输入要查询的年份:");
scanf ("%d",&y);
w=(y-1)*365+(y-1)/4-(y-1)/100+(y-1)/400+1;
s1=s2=w1=w2=w%7;
for(num=1;num<=12;num++)
{
printf(" %d月",num++);
printf(" %d月\n\n",num);
printf(" 日 一 二 三 四 五 六 日 一 二 三 四 五 六\n");
switch (--num)//一月份的天数
{
case 1: m1=31;break;
case 3: m1=31;break;
case 5: m1=31;break;
case 7: m1=31;break;
case 9: m1=30;break;
case 11: m1=30;break;
}
switch (++num)//二月份的天数
{
case 2: m2=28;
if ((y%4==0&&y%100!=0)||(y%400==0)) m2=29;break;
case 4: m2=30;break;
case 6: m2=31;break;
case 8: m2=31;break;
case 10: m2=31;break;
case 12: m2=31;break;
}
s1=w1=w%7;d1=1;
s2=w2=(w1+m1)%7; d2=1;
switch(s1)//月份第一天前面空格数
{
case 0: printf("%5d",d1);break;
case 1: printf("%10d",d1);break;
case 2: printf("%15d",d1);break;
case 3: printf("%20d",d1);break;
case 4: printf("%25d",d1);break;
case 5: printf("%30d",d1);break;
case 6: printf("%35d",d1);break;
} w1++;
if (w1%7==0) goto area21;
area11:for(;d1<=m1;d1++)
{
printf("5d",d1);w1++;
if(w1%7==0) goto area21;
}
area12:for(;d1<=m1;d1++)
{
printf ("%5d",d1); w1++;
if (w1%7==0) goto area22;
}
area21:switch (s2)
{
case 0: printf("%5d",d2);break;
case 1: printf("%10d",d2);break;
case 2: printf("%15d",d2);break;
case 3: printf("%20d",d2);break;
case 4: printf("%25d",d2);break;
case 5: printf("%30d",d2);break;
case 6: printf("%35d",d2);break;
} w2++;
if (w2%7==0) goto area12;
area22:for(;d2<=m2;d2++)
{
printf("5d",d2);w2++;
if (w2%7==0) goto area12;
}
goto area12;
}
}
可是出不来结果,高数指错。谢谢谢谢