雨晴啊
2018-08-24 18:35
#include <stdio.h>
int main()
{
/* 定义需要计算的日期 */
int year = 2008;
int month = 7;
int day = 8;
int total=0;
switch(month)
{
case 1:total+=31;
case 2:
if(year%4==0&&year%100==0&&year%400!=0)
{total+=29;}
else{
total+=28;
}
case 3:total+=31;
case 4:total+=30;
case 5:total+=31;
case 6:total+=30;
case 7:total+=31;
case 8:total+=31;
case 9:total+=30;
case 10:total+=31;
case 11:total+=30;
case 12:total+=31;
}
total=total+day+1;
printf("%d年%d月%d日是该年的%d天",year,month,day,total);
return 0;
}
请问哪里出了问题
最后输出的total为什么要在加一个1呢
闰年判断错了
if(year%400==0||year%100!=0&&year%4==0)
C语言入门
926020 学习 · 20793 问题
相似问题