#include<stdio.h>
int main() { int year, mon, day, isLeap, i, count; int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
printf("輸入日期:(輸入格式必須為yyyy-mm-dd,如2012-11-24)\n"); scanf("%d-%d-%d", &year, &mon, &day);
//判斷是否為潤年 if ((year % 400 == 0) || (year % 100 != 0 && year % 4 == 0) ) isLeap = 1;
else isLeap = 0; count = 0; month[2] = month[2] + isLeap; for (i = 1; i < mon; i++){ count += month[i]; } count += day; printf("%d-%d-%d是%d年中的第%d天./n", year, mon, day,year, count);
return 0;
}
|