#include <iostream>
using namespace std;
int main(){
int year, month, day,s;
char c;
while (cin >> year >> c >> month >> c >> day){
switch (month){
case 1:s = 0; break;
case 2:s = 31; break;
case 3:s = 59; break;
case 4:s = 90; break;
case 5:s = 120; break;
case 6:s = 151; break;
case 7:s = 181; break;
case 8:s = 212; break;
case 9:s = 243; break;
case 10:s = 273; break;
case 11:s = 304; break;
case 12:s = 334; break;
default:cout << "error" << endl; break;
}
if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)){
if (month > 2) s += 1;
}
cout << s + day << endl;
}
return 0;
}
年月日输入、读取
闰年
2月
月份对应天数