c语言天数求解问题,哪里错了

2024-11-23 06:12:09
推荐回答(1个)
回答1:

#include
int main ()
{int days,m,year,month,day;
scanf("%d-%d-%d",&year,&month,&day);
days=0;
for(m=1;mif(m==2)

if((year%4==0&&year%100!=0)||(year%400==0))
days=days+29;
else
days=days+28;

else

if(m==1||m==3||m==5||m==7||m==8||m==10)
days=days+31;
else
days=days+30;

days=days+day;
printf("%d-%d-%d是第%d天\n",year,month,day,days);
return 0;
}