文章
64
粉丝
100
获赞
4
访问
36.2k
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int m,year,month,day,days;
scanf("%d",&m);
while(m--)
{
scanf("%d %d %d %d",&year,&month,&day,&days);
days=days+day;
while(days>a[month])
{
if(year%4==0&&year%100!=0||year%400==0)
a[2]=29;
else
&nb...
登录后发布评论
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int m,year,month,day,days;
scanf("%d",&m);
while(m--)
{
scanf("%d %d %d %d",&year,&month,&day,&days);
if(year%4==0&&year%100!=0||year%400==0)
a[2]=29;
else
a[2]=28;
days=days+day;
while(days>a[month])
{
days=days-a[month];
month++;
if(month>12)
{
year++;
month=month-12;
}
if(year%4==0&&year%100!=0||year%400==0)
a[2]=29;
else
a[2]=28;
}
printf("%d-%02d-%02d\n",year,month,days);
}
}
你的days会减到0,但是没有0号这个说法