根据年月日,判断已经多少天(3)
#include<stdio.h>
int main(void)
{
int year,month,days=0,day,flag,sum=0;int i=1;
scanf("%d",&year);
scanf("%d",&month);
scanf("%d",&day);
if(year%400==0)
flag=1;
else if(year%4==0&&year%100!=0)
flag=1;
else
flag=0;
for(i=1;i<month;i++)
{
switch(i)
{
case 2:
{if(flag==1)
days=29;
else
days=28;
}break;
case 4:
case 6:
case 9:
case 11:days=30;break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:days=31;break;
}
sum+=days;
}
sum=sum+day;
printf("%d\n",sum);
return 0;
}