题解 | #日期类#
日期类
https://www.nowcoder.com/practice/130aa2d7d1f5436b920229dca253893b
#include <cstdio> int main() { int n; int mdays[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (scanf("%d", &n) != EOF) { int year, month, day; for (int i = 0; i < n; ++i) { scanf("%d%d%d", &year, &month, &day); day++; if (day > mdays[month]) { month++; day = 1; if (month > 12) { year++; month = 1; } } printf("%04d-%02d-%02d\n", year, month, day); } } }