1 条题解
-
-1魏然@苏州湾实验初级中学 (魏然同学) LV 10 @ 2021-03-30 20:08:24
#include <iostream> using namespace std; int year, month, day; int cnt(0); int test_day(const unsigned int &year, const unsigned int &month); int main() { cin>>year>>month>>day; while (cnt != 10000) { if (day == test_day(year, month)) if (month == 12) { ++year; month = day = 1; } else { ++month; day = 1; } else ++day; ++cnt; } cout<<year<<"-"<<month<<"-"<<day; return 0; } int test_day(const unsigned int &year, const unsigned int &month) { if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) return 31; if (month == 2) return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 29 : 28; return 30; }
- 1