貌似弄错了 闰年的二月是29天 还有是没考虑一月的时候
不用写这个
if(Isleapyear(year))
count--;
下面是修改的代码 呵呵
#include <stdio.h>
int Isleapyear(int year)
{
if((year%4==0)&&(year%100!=0)||(year%400==0))
return 1;
else
return 0;
}
int main()
{
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int year,month,day,count=0;
int i;
printf("please input the year month and the day\n");
scanf("%d%d%d",&year,&month,&day);
for(i=0;i<month;i++)
count+=a[i];
count+=day;
if(month>=2&&Isleapyear(year))
count++;
printf("%d",count);
}
不用写这个
if(Isleapyear(year))
count--;
下面是修改的代码 呵呵
#include <stdio.h>
int Isleapyear(int year)
{
if((year%4==0)&&(year%100!=0)||(year%400==0))
return 1;
else
return 0;
}
int main()
{
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int year,month,day,count=0;
int i;
printf("please input the year month and the day\n");
scanf("%d%d%d",&year,&month,&day);
for(i=0;i<month;i++)
count+=a[i];
count+=day;
if(month>=2&&Isleapyear(year))
count++;
printf("%d",count);
}