纯C
#include <stdlib.h> #include <stdio.h> int main() { int month_days[12] = {31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; int year, month, day; while(scanf("%d %d %d\n", &year, &month, &day) != EOF) { int days = 0; if(month >= 2) days = month_days[month - 2] + day; else days = day; if((year%4 == 0 && year%100 != 0) || year %400 == 0) days ++; printf("%d\n", days); } return 0; }