非常经典的板子,用于计算两个日期之间的差值或者累加天数
#include<bits/stdc++.h>
using namespace std;
int month[13][2]={{0,0},{31,31},{28,29},{31,31},{30,30},{31,31},{30,30},{31,31},{31,31},{30,30},{31,31},{30,30},{31,31}};
bool isLeap(int y){
return ((y%4==0 && y%100!=0) || y%400==0);
}
int main(){
int y,m,d,n,x;
while(cin>>n){
while(n--){
cin>>y>>m>>d>>x;
while(x--){
d++;
if(d == month[m][isLeap(y)] + 1){ //满当月天数
m++;
d=1;
}
if(m == 13){ //满12个月
y++;
m=1;
}
}
printf("%04d-%02d-%02d\n",y,m,d);
}
}
return 0;
}