#include<iostream> #include<algorithm> #include<string> using namespace std; void nextday(int& y, int& m, int& d) { int dayMonth[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; bool isLeap = y % 400 == 0 || y % 4 == 0 && y % 100 != 0; if (isLeap) { dayMonth[2] = 29; } else { dayMonth[2] = 28; } d++; if (d > dayMonth[m]) { m++; d = 1; } if (m > 12) { m = 1; y++; } } int main() { int n; int year, month, day, t; cin >> n; for (int i = 0; i < n; i++) { cin >> year >> month >>day >> t; while (t != 0) { t--; nextday(year, month, day); } printf("%04d-%02d-%02d\n", year, month, day);//格式化控制输出,别忘了最后要输出换行 } return 0; }