/*
2022年3月29日14点15分
输入年份、月份、日期,输出这一天是该年份下的第几天。
*/
#include <iostream>
using namespace std;
int run(int year)
{
if (year % 4 == 0 && year % 100 != 0) return true;
else if (year % 400 == 0) return true;
else return false;
}
int result(int year,int month,int day)
{
int sum = 0, a;
if (run(year)) a = 29;
else a = 28;
switch(month)
{
case 1: sum += day; break;
case 2: sum += 31 + day; break;
case 3: sum += 31 + a + day; break;
case 4: sum += 31 + a + 31 + day; break;
case 5: sum += 31 + a + 31 + 30 + day; break;
case 6: sum += 31 + a + 31 + 30 + 31 + day; break;
case 7: sum += 31 + a + 31 + 30 + 31 + 30 + day; break;
case 8: sum += 31 + a + 31 + 30 + 31 + 30 + 31 + day; break;
case 9: sum += 31 + a + 31 + 30 + 31 + 30 + 31 + 31 + day; break;
case 10: sum += 31 + a + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day; break;
case 11: sum += 31 + a + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day; break;
case 12: sum += 31 + a + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day; break;
}
return sum;
}
int main()
{
int year, month, day;
cout << "请输入年份:" << endl;
cin >> year;
cout << "请输入月份:" << endl;
cin >> month;
cout << "请输入日期:" << endl;
cin >> day;
cout << "今天是" << year << "的第" << result(year, month, day) << "天" << endl;
return 0;
}