123456789
2024-10-13 14:04:03
发布于:广东
1
全部评论 2
#include <bits/stdc++.h> using namespace std; long long y,m,d,h,mn,s,x,sum,a[410],b[20]; void init() { for(int i = 0;i < 400;i++) { a[i] = 365; if(i % 4 == 0 && i % 100 != 0 || i % 400 == 0) a[i]++; sum += a[i]; } for(int i = 1;i <= 12;i++) { if(i == 1 || i == 3 || i == 5 || i == 7) b[i] = 31; else if(i == 8 || i == 10 || i == 12) b[i] = 31; else if(i == 4 || i == 6 || i == 9 || i == 11) b[i] = 30; } } bool f(int tmp) { return a[tmp % 400] == 366; } int main() { //freopen("D6T3.in","r",stdin); //freopen("D6T3.out","w",stdout); init(); scanf("%lld%lld%lld%lld%lld%lld%lld",&y,&m,&d,&h,&mn,&s,&x); s += x; mn += s / 60; s %= 60; h += mn / 60; mn %= 60; d += h / 24; h %= 24; while(d > sum) { d -= sum; y += 400; } while(d > a[y % 400]) { d -= a[y % 400]; y++; } while(d > b[m]) { if(m == 2) { if(f(y) && d > 29) { d -= 29; m++; } else if(!f(y) && d > 28) { d -= 28; m++; } else break; } else { d -= b[m]; m++; } if(m > 12) m -= 12; } printf("%lld %lld %lld %lld %lld %lld\n",y,m,d,h,mn,s); //fclose(stdin); //fclose(stdout); return 0; }
2024-10-13 来自 广东
02
2024-10-13 来自 广东
0
有帮助,赞一个