ClaireChenyolo
2019-10-16 21:51
#include <stdio.h>
int main()
{
int year = 2008;
int month = 8;
int day = 8;
int sum=0;
month=month-1;
switch (month)
{
case 12: sum+=31;
case 11: sum+=30;
case 10: sum+=31;
case 9: sum+=30;
case 8: sum+=31;
case 7: sum+=31;
case 6: sum+=30;
case 5: sum+=31;
case 4: sum+=30;
case 3: sum+=31;
case 2: sum+=28;
case 1: sum+=31;
break;
}
sum+=day;
if((year%400==0)||(year%100!=0&&year%4==0))
{
if(month>2)
sum+=1;
}
printf("%d",sum);
return 0;
}
你的month在之前减了1,所以 if(month>2)应该改成 if(month>=2)
弱弱的问一句,month为什么要减去1呢?
C语言入门
926028 学习 · 20793 问题
相似问题