只是出來結果220
#include <stdio.h>
int main()?
{?
? ? /* 定義需要計算的日期 */
? ? int year = 2008;
? ? int month = 8;
? ? int day = 8;
? ? int i,j;
? ? switch(month)
? ? {
? ? ? ? case 1:j=0;break;
? ? ? ? case 2:j=30;break;
? ? ? ? case 3:j=30+28;break;
? ? ? ? case 4:j=30+28+31;break;
? ? ? ? case 5:j=30+28+31+30;break;
? ? ? ? case 6:j=30+28+31+30+31;break;
? ? ? ? case 7:j=30+28+31+30+31+30;break;
? ? ? ? case 8:j=30+28+31+30+31+30+31;break;
? ? ? ? case 9:j=30+28+31+30+31+30+31+31;break;
? ? ? ? case 10:j=30+28+31+30+31+30+31+31+30;break;
? ? ? ? case 11:j=30+28+31+30+31+30+31+31+30+31;break;
? ? ? ? case 12:j=30+28+31+30+31+30+31+31+30+31+30;break;
? ? }
? ? if(year%4==0&&year%100!=0||year%400==0)
? ? {
? ? ? ? day=j+day+1;?
? ? ? ? printf("%d",day);
? ? }
? ? else
? ? {
? ? ? ? day=j+day;
? ? ? ? printf("%d",day);
? ? }
return 0;
}
2018-12-17
1月是31天,不是30天,你的程序里1月算成30天了