sunshine1174
2020-09-24 18:48
#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;
}
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;
}
自己检查了一遍发现int da =0 忘了加;
C语言入门
926207 学习 · 20797 问题
相似问题