我按照日期计算器的形式写的不知道对不对,请求大家帮我看下对不对?我自己没发现问题
#include <stdio.h>
int main()
{
int year = 2008;
int month = 8;
int day = 8;
int sum;
switch(year%400==0||(year%4==0&&year%100!=0))
{
case 1:
if(month%2==0)
{
sum = ((month-1)-1)/2*31 + (((month-1)-1)/2-1)*30 + 31 + 29 + day;
}else
{
sum = (month-1)/2*31 + ((month-1)-1)/2*30 + 29 + day;
}
break;
case 0:
if(month%2==0)
{
sum = ((month-1)-1)/2*31 + (((month-1)-1)/2-1)*30 + 31 + 28 + day;
}else
{
sum = (month-1)/2*31 + ((month-1)-1)/2*30 + 28 + day;
}
break;
}
printf("%d年%d月%d日是该年的第%d天",year,month,day,sum);