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