8 回答
TA贡献1017条经验 获得超1032个赞
#include<stdio.h> int main() { int year=2008; int month=8; int day=8; int days=0; int i=1; for(i;i<month;i++) { switch(i) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: days=days+31;break; case 2: days=days+28;break; case 4: case 6: case 9: case 11: days=days+30;break; } } days=days+day; if(year%4==0&&year%100!=0||year%400==0) { days=days+1; } printf("%d\n",days); return 0; }
TA贡献4条经验 获得超0个赞
你说的对,改成i后结果还是不对,结果输出是374,还有哪里错吗
#include<stdio.h>
int main()
{
int year=2008;
int month=8;
int day=8;
int days=0;
int i=1;
int month=month-1;
for(i;i<=month;i++)
{
switch(i)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
days=days+31;
continue;
case 2:
days=days+28;
continue;
case 4:
case 6:
case 9:
case 11:
days=days+30;
continue;
}
}
days=days+day;
if(year%4==0&&year%100!=0||year%400==0)
{
days=days+1;
}
printf("%d",days);
return 0;
}
TA贡献4条经验 获得超0个赞
你说的对,改成i后结果还是不对,结果输出是374,还有哪里错吗
#include<stdio.h>
int main()
{
int year=2008;
int month=8;
int day=8;
int days=0;
int i=1;
int month=month-1;
for(i;i<=month;i++)
{
switch(i)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
days=days+31;
continue;
case 2:
days=days+28;
continue;
case 4:
case 6:
case 9:
case 11:
days=days+30;
continue;
}
}
days=days+day;
if(year%4==0&&year%100!=0||year%400==0)
{
days=days+1;
}
printf("%d",days);
return 0;
}
- 8 回答
- 3 关注
- 2571 浏览
添加回答
举报