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 關注
- 2725 瀏覽
添加回答
舉報