题解 | 日期类
#include <cstdio> #include <iostream> using namespace std; int mon[130]={0,31,28,31,30,31,30,31,31,30,31,30,31}; bool run(int year){ return year%4==0&&year%100!=0 || year%400 == 0; } int main() { int m,a,b,c; cin>>m; while(m--){ mon[2] = 28; cin>>a>>b>>c; if(run(a)){ mon[2] = 29; } c++; if(c>mon[b]){ b++; if(b>12) a++; c= 1; } printf("%04d-%02d-%02d\n",a,b,c); } } // 64 位输出请用 printf("%lld")