为什么打印那块有的月份少一天
#include<stdio.h>#include<string.h>
void xingqiji();
int runnian(int year);
void runnian1();
void print();
int main()
{
int i,j=1;
char s;
while(j==1)
{
printf("\t1、查询某年某月是星期几\n");
printf("\t2、查询某年是否是闰年\n");
printf("\t3、打印某年全年日历\n");
printf("\t4、退出\n");
printf("\t请选择。。。。。。\n");
scanf("%d",&i);
switch(i)
{
case 1:xingqiji();break;
case 2:runnian1();break;
case 3:print();break;
case 4:break;
}
printf("是否返回主菜单('Y'or'N')?\n");
fflush(stdin);
scanf("%c",&s);
if(s=='y'||s=='Y')
{
j=1;
}
else
break;
}
return 0;
}
/*判断星期几*/
void xingqiji()
{
int year,month,day,flag;
int i,count=0,s;
int a[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
printf("请输入年月日\n");
scanf("%d%d%d",&year,&month,&day);
flag=runnian(year);
if(flag==1)
a[2]++;
for(i=1;i<month;i++)
{
count+=a[i];
}
count+=day;
s=year+1+(year-1)/4+(year-1)/100+(year-1)/400+count;
s=s%7;
printf("%d年 %d月 %d日是星期%d\n",year,month,day,s);
}
/*判断闰年*/
int runnian(int year)
{
if(year%4==0&&year%100||year%400==0)
return 1;
else
return 0;
}
/*输出是否是闰年*/
void runnian1()
{
int year;
printf("请输入年份");
scanf("%d",&year);
if(year%4==0&&year%100||year%400==0)
printf("%d 是闰年\n",year);
else
printf("%d 不是闰年\n",year);
}
/*打印*/
void print()
{
int m,i,s,a[40],year,month,h=1,count,j;
int b[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
char d;
while(h==1)
{
printf("请输入要打印的年份\n");
scanf("%d",&year);
for(month=1;month<=12;month++)
{
count=0;
for(j=1;j<month;j++)
count+=b[j];
m=1;
printf("\t%d年%d月\n",year,month);
printf(" 1 2 3 4 5 6 7\n");
s=year+1+(year-1)/4+(year-1)/100+(year-1)/400+count+1;
s=s%7;
for(i=1;i<=b[month]+s;i++)
{
if(i<s)
a[i]=0;
if(i==s)
a[i]=m++;
if(i>s)
a[i]=m++;
}
for(i=1;i<b[month]+s;i++)
{
printf("%d ",a[i]);
if(i%7==0)
printf("\n");
}
printf("\n");
}
printf("是否继续\n");
scanf("%c",&d);
if(d=='y'||d=='Y')
{
h=1;
}
else break;
}
}