恋爱纪念日_算法

#include <iostream>
#include <string.h>
using namespace std;

int main() {
int y, m, d, k;
cin >> y >> m >> d >> k;
int day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
for (int i = 1; i <= k; i++) {
if ((y % 400 == 0) || (y % 100 && y % 4 == 0)) {
day[3] = 29;
} else {
day[3] = 28;
}
d++;
if (d == day[m] + 1) {
d = 1;
m++;
}
if (m == 13) {
m = 1;
y++;
}
}
printf("%4d-%02d-%02d\n", y, m, d);
return 0;
}

恋爱纪念日_数据结构_02