有会的小伙伴么,帮我改下,我不知道怎么改了
#include <stdio.h>
int main()
{
/* 定义需要计算的日期 */
int year = 2008;
int month = 8;
int day = 8;
/*
* 请使用switch语句,if...else语句完成本题
* 如有想看小编思路的,可以点击左侧任务中的“不会了怎么办”
* 小编还是希望大家独立完成哦~
*/
int y;
int sum;
switch(month-1)
{
case 1:y=31;break;
case 2:y=31+28;break;
case 3:y=31+28+31;break;
case 4:y=31+28+31+30;break;
case 5:y=31+28+31+30+31;break;
case 6:y=31+28+31+30+31+30;break;
case 7:y=31+28+31+30+31+30+31;break;
case 8:y=31+28+31+30+31+30+31+31;break;
case 9:y=31+28+31+30+31+30+31+31+30;break;
case 10:y=31+28+31+30+31+30+31+31+30+31;break;
case 11:y=31+28+31+30+31+30+31+31+30+31+30;break;
case 12:y=31+28+31+30+31+30+31+31+30+31+30+31;break;
default:printf("ERROR!!!一年只有12个月!!!");break;
}
if(year%4==0&&year%100!=0&&year%400==0)
{
if(month>=2&&month<=12)
{
sum=y+day+1;
printf("%d年%d月%d日是%d天\n",year,month,day,sum);
}
else
{
sum=y+day;
printf("%d年%d月%d日是%d天\n",year,month,day,sum);
}
}
else
{
sum=y+day;
printf("%d年%d月%d日是%d天\n",year,month,day,sum);
}
return 0;
}