注意个位数日期前面要有0。
#include<stdio.h>
#include<iostream>
using namespace std;
void fun(int year,int month,int day);
//不行我这个太麻烦了,看看人家的笔记
int main()
{
int m;
int n[3];
cin >> m;
for(int i=0;i<m;i++)
{
cin >> n[0] >> n[1] >> n[2];
fun(n[0],n[1],n[2]);
}
return 0;
}
void fun(int year,int month,int day)
{
if(month==12 && day==31)
{
month = 1; day = 1;
cout << year+1 <<"-0"<<month<<"-0"<<day<<endl;
}
else if((month==1||month==3||month==5||month==7||month==8||month==10)&&day==31){
day=1;
if(month<9) cout << year << "-0" <<month+1<<"-0"<<day<<endl;
else cout << year << "-" <<month+1<<"-0"<<day<<endl;
}
else if((month==6||month==9||month==11)&&day==30){
day=1;
if(month<9) cout << year << "-0" <<month+1<<"-0"<<day<<endl;
else cout << year << "-" <<month+1<<"-0"<<day<<endl;
}else if(month==2 && day==28)
{
day=1;
cout << year << "-0" <<month+1<<"-0"<<day<<endl;
}
else{
if(month<9){
if(day<9){
cout << year << "-0" <<month<<"-0"<<day+1<<endl;
}
else{
cout << year << "-0" <<month<<"-"<<day+1<<endl;
}
}
else{//month>=9
if(month==9){
if(day<9){
cout << year << "-0" <<month<<"-0"<<day+1<<endl;
}
else{
cout << year << "-0" <<month<<"-"<<day+1<<endl;
}
}
else{
if(day<9){
cout << year << "-" <<month<<"-0"<<day+1<<endl;
}
else{
cout << year << "-" <<month<<"-"<<day+1<<endl;
}
}
}
}
}