求大佬看看問題
#include <stdio.h>
int main()?
{?
? ? int year = 2008;
? ? int month = 8;
? ? int day = 8;
? ? int da=0
? ? switch (month)
? ? {
? ? ? ? ?case 1:da+=31;
? ? ? ? ?case 2:if(year&400==0 ||(year%4==0&&year%100!=0))
? ? ? ? ? ? ? ? ? ? da+=29;
? ? ? ? ? ? ? ? else da+=28;
? ? ? ? ?case 3:da+=31;
? ? ? ? ?case 4:da+=30;
? ? ? ? ?case 5:da+=31;
? ? ? ? ?case 6:da+=30;
? ? ? ? ?case 7:da+=31;
? ? ? ? ?case 8:da+=31;
? ? ? ? ?case 9:da+=30;
? ? ? ? ?case 10:da+=31;
? ? ? ? ?case 11:da+=30;
? ? ? ? ?case 12:da+=31;
? ? ? ? break;
? ? ?
? ? ?da=da+day;
? ? printf("%d年%d月%d日是該年的第%d天",year,month,day,da);
}
return 0;
}
2020-09-25
int main()?
{?
? ? int year = 2008;
? ? int month = 8;
? ? int day = 8;
? ? int da=1;
? ? switch (month)
? ? {
? ? ? ? ?case 1:da+=31;
? ? ? ? ?case 2:if(year&400==0 ||(year%4==0&&year%100!=0))
? ? ? ? ? ? ? ? ? ? da+=29;
? ? ? ? ? ? ? ? else da+=28;
? ? ? ? ?case 3:da+=31;
? ? ? ? ?case 4:da+=30;
? ? ? ? ?case 5:da+=31;
? ? ? ? ?case 6:da+=30;
? ? ? ? ?case 7:da+=31;
? ? ? ? ?case 8:da+=31;
? ? ? ? ?case 9:da+=30;
? ? ? ? ?case 10:da+=31;
? ? ? ? ?case 11:da+=30;
? ? ? ? ?case 12:da+=31;
? ? ? ? break;
? ? ?
? ? ?da=da+day;
? ? printf("%d年%d月%d日是該年的第%d天",year,month,day,da);
}
return 0;
}
2020-09-24
自己檢查了一遍發(fā)現(xiàn)int da =0 忘了加;