19机科3班汤浩419240338
2020-05-28 16:31
#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;
}
”输出错误“只是因为你的printf里面的输出和小编规定的不一样,因此而已。运行成功了就可以了。
C语言入门
926025 学习 · 20793 问题
相似问题