AcWing 3564. 日期类
原题链接
简单
作者:
cbh
,
2022-07-05 08:54:18
,
所有人可见
,
阅读 155
这应该是新手最最最容易懂的写法了
#include<bits/stdc++.h>
using namespace std;
int monthes[20]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int n;
int main(){
cin>>n;
while(n--){
int year,month,day;
cin>>year>>month>>day;
if(day+1>monthes[month]){
day=1;
if(month+1>12){
month=1;
year++;
}
else month++;
}
else day++;
cout<<year<<"-";
if(month<10) cout<<0<<month<<"-";
else cout<<month<<"-";
if(day<10) cout<<0<<day<<endl;
else cout<<day<<endl;
}
return 0;
}