解题思路:
注意事项:
参考代码:
#include<stdio.h>
int Judge(int year)
{
if((year%4==0&&year%100!=0)||year%400==0)
{
return 1;
}
else
return 0;
}
typedef struct Date
{
int year;
int month;
int day;
}Date;
int main()
{
Date date;
int month[12]={31,0,31,30,31,30,31,31,30,31,30,31},i,sum=0;
scanf("%d %d %d",&date.year,&date.month,&date.day);
if(Judge(date.year))
{
if(date.month==1)
{
sum=date.day;
}
else
{
for(i=0;i<date.month-1;i++)
{
if(i==1)
{
sum+=29;
continue;
}
sum=sum+month[i];
}
sum+=date.day;
}
}
else
{
if(date.month==1)
{
sum=date.day;
}
else
{
for(i=0;i<date.month-1;i++)
{
if(i==1)
{
sum+=28;
continue;
}
sum=sum+month[i];
}
sum+=date.day;
}
}
printf("%d",sum);
return 0;
}
0.0分
0 人评分