注意是05-13,不是5-13
#include<stdio.h>
#include
using namespace std;
int isleap(int year)
{
return ((year%40 && year%100!=0)||(year%4000));
}
int getday(int month,int year)
{
switch(month)
{
case 1:case 3:case 5:case 7:case 8:case 10:case 12:
return 31;
break;
case 4:case 6:case 9:case 11:
return 30;
break;
case 2:
if(isleap(year)) return 29;
else return 28;
}
}
int main()
{
int n,i,j;
int y,m,d,day;
cin>>n;
for(i=0;i<n;i++)
{
cin>>y>>m>>d>>day;
for(j=0;j<day;j++)
{ d++;
if(d>getday(m,y))
{d=1;m++;
if(m>12)
{y++;m=1;}}}
if(m>=10 && d>10)
cout<<y<<"-"<<m<<"-"<<d<<endl;
else if(m<10 && d<10)
cout<<y<<"-0"<<m<<"-0"<<d<<endl;
else if(m<10)
cout<<y<<"-0"<<m<<"-"<<d<<endl;
else if(d<10)
cout<<y<<"-"<<m<<"-0"<<d<<endl;
}
return 0;
}