目录
- #include
- using namespace std;
- class Date {
- public:
- Date(int year = 1, int month = 2, int day = 3)
- {
- _year = year;
- _month = month;
- _day = day;
- }
- int GetDay(int year, int month);//得到某年某月的天数
-
- public:
- int _year;
- int _month;
- int _day;
- };
- int Date::GetDay(int year, int month)
- {
- static int a[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- if (month == 2)
- {
- if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
- return 29;
- }
- return a[month];
- }
-
-
- int main()
- {
- int year, month, day;
- cin >> year;
- cin >> month;
- cin >> day;
- int _Count = day;
- for (int i = 1; i < month; i++)
- {
- Date date;
- _Count += date.GetDay(year, i);
- }
- cout << _Count;
- return 0;
-
- }
- // 64 位输出请用 printf("%lld")