1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 int main() 6 { 7 int year,month,day; 8 9 char a; 10 int days_of_month1[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};//闰年 11 int days_of_month2[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};//非闰年 12 while (cin >> year >> a >> month >> a >>day) 13 { 14 int flag = 0; 15 int sum = 0; 16 if (((year%4==0) && (year%100!=0)) || (year%400==0)) 17 { 18 flag = 1; 19 } 20 21 if (flag) 22 { 23 for (int i = 0; i < month; i++) 24 { 25 sum += days_of_month1[i]; 26 } 27 } 28 else 29 { 30 for (int i = 0; i < month; i++) 31 { 32 sum += days_of_month2[i]; 33 } 34 } 35 sum += day; 36 cout<< sum <<endl; 37 } 38 return 0; 39 }