设计思路应该没有问题呀,为什么总显示输出错误?
#include <stdio.h>
int main()
{
int year = 2008;
int month = 8;
int day = 8;
int numbers;
if(year%4==0 && year%100!=0 || year%400==0)
{
switch(month)
{
case 1:
case 2:
numbers = (month-1)*31 + day;
printf("该日期对应该年的%d天",numbers);
break;
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
numbers = (month/2)*31 + ((month-3)/2)*30 + 29 + day;
printf("该日期对应该年的%d天",numbers);
break;
default:
numbers = ((month+1)/2)*31 + ((month-4)/2)*30 + 29 + day;
printf("该日期对应该年的%d天",numbers);
break;
}
}
else
{
switch(month)
{
case 1:
case 2:
numbers = (month-1)*31 + day;
printf("该日期对应该年的%d天",numbers);
break;
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
numbers = (month/2)*31 + ((month-3)/2)*30 + 28 + day;
printf("该日期对应该年的%d天",numbers);
break;
default:
numbers = ((month+1)/2)*31 + ((month-4)/2)*30 + 28 + day;
printf("该日期对应该年的%d天",numbers);
break;
}
}
return 0;
}