文章
84
粉丝
408
获赞
33
访问
872.2k
#include<iostream>
#include<cstdio>
using namespace std;
int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool extra(int y)
{
if (y%400)
return true;
else if (y%100 != 0 && y%4==0)
return true;
else
return false;
}
void add_one(int y, int m, int d)
{
d += 1;
if (m == 2) {
if (d == 30 && extra(y) || d == 29 && extra(y)) {
m += 1;
d = 1;
}
}
else {
if (d > days[m]) {
m += 1;
d = 1;
}
}
if (m == 13) {
y += 1;
m = 1;
}
printf("%d-%02d-%02d\n", y, m, d);
}
int main()
{
int m;
cin >> m;
while (m--) {
int y, m, d;
cin >> y >> m >> d;
add_one(y, m, d);
}
return 0;
}
登录后发布评论
#include<bits/stdc++.h>
using namespace std;
int days[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool extra(int y)
{
if(y%400==0)//判断世纪润年,错误1
return true;
else
{
if(y%100!=0&&y%4==0)
return true;
else
return false;
}
}
void add_one(int y,int m,int d)
{
d+=1;
if(m==2)
{
printf("%d\n",extra(y));
if((d==30&&extra(y))||(d==29&&!extra(y)))//判断非闰年跨月,错误2
{
m+=1;
d=1;
}
}
else
{
if(d>days[m])
{
m+=1;
d=1;
}
}
if(m==13)
{
y+=1;
m=1;
}
printf("%d-%02d-%02d\n",y,m,d);
}
int main()
{
int m;
cin>>m;
while(m--)
{
int y,m,d;
cin>>y>>m>>d;
add_one(y,m,d);
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int days[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool extra(int y)
{
if(y%400==0)//判断世纪润年,源(up主)代码错误
return true;
else
{
if(y%100!=0&&y%4==0)
return true;
else
return false;
}
}
void add_one(int y,int m,int d)
{
d+=1;
if(m==2)
{
printf("%d\n",extra(y));
if((d==30&&extra(y))||(d==29&&!extra(y)))
{
m+=1;
d=1;
}
}
else
{
if(d>days[m])
{
m+=1;
d=1;
}
}
if(m==13)
{
y+=1;
m=1;
}
printf("%d-%02d-%02d\n",y,m,d);
}
int main()
{
int m;
cin>>m;
while(m--)
{
int y,m,d;
cin>>y>>m>>d;
add_one(y,m,d);
}
return 0;
}