文章
8
粉丝
14
获赞
1
访问
9.0k
//AC代码
//方法一---一天一天加
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin >> a;
int f[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 ,31};
while(a--) {
int y, m, d, n;
cin >> y >> m >> d >> n;
if(y % 400 == 0 || y % 4 == 0 && y % 100 != 0)
f[1] = 29;
else
f[1] = 28;
for(int i = 1; i <= n; i++) {
if(d + 1 > f[m - 1]) {
if(m + 1 > 12) {
m = 1;
y += 1;
if(y % 400 == 0 || y % 4 == 0 && y % 100 != 0)
f[1] = 29;
else
f[1] = 28;
}
else {
m += 1;
}
d = 1;
}
else {
d += 1;
}
}
printf("%04d-%02d-%02d\n", y, m, d);
}
return 0;
}
//按月来减
#include<bits/stdc++.h>
using namespace std;
int main() {
int a;
cin >> a;
int f[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 ,31};
while(a--) {
int y, m, d, n;
cin >> y &...
登录后发布评论
暂无评论,来抢沙发