文章
8
粉丝
216
获赞
20
访问
67.6k
#include<bits/stdc++.h>
using namespace std;
int tab[2][13] = {
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
};
bool LeapYear(int year){
return ( (!(year%4) && year%100) || !(year%400) );
}
int DaysOfYear(int year){
if(LeapYear(year))
return 366;
else
return 365;
}
int main(){
int num;
scanf("%d", &num);
while(num--){
int year, month, day, n;
scanf("%d %d %d %d", &year,&month,&day,&n);
//计算出从year开始加上天数共有多少天
for(int i=1; i<month; i++)
n += tab[LeapYear(year)][i];
n += day;
//刚好为一整年
if(n==DaysOfYear(year)){
year += 1;
month = 1;
day = 1;
}
//经过了很多个整年
else if(n>DaysOfYear(year)){
int t = n/DaysOfYear(year);
year += t;
int sum = 0;
for(int i = year-t; i<year; i++){
sum += DaysOfYear(i);
}
//定位至某一年后再进行定位具体日期
sum = n - sum;
for(month=1; ; month++){
su...
登录后发布评论
暂无评论,来抢沙发