#include <iostream> using namespace std; int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool isLeap(int year) { if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0) { return true; } return false; } int main() { int m; while (scanf("%d", &m) != EOF) { // 注意 while 处理多个 case for (int j = 0; j < m; j++) { // m个日期 int year, month, day, num; scanf("%d%d%d%d", &year, &month, &day, &num); if (isLeap(year)) { days[2] = 29; } else { days[2] = 28; } for (int i = 0; i < num; i++) { day++; if (day > days[month]) { month++; day = 1; } if (month > 12) { year++; if (isLeap(year)) { //年份改变了要看看是不是闰年 days[2] = 29; } else { days[2] = 28; } month = 1; } } printf("%d-%02d-%02d\n", year, month, day); } } } // 64 位输出请用 printf("%lld")