#include<bits/stdc++.h>
using namespace std;
void rl(int q){
int year=-4712,mon=1,day=1,month[]={29,31,28,31,30,31,30,31,31,30,31,30,31};
year+=q/1461;
for(int i=1;i<=q%1461;i++){
if(abs(year)%4==0){month[2]==29;}else {month[2]==29;}
day++;
if(day>month[mon]){day=1;mon++;cout<<month[mon]<<" ";}
if(mon>12){year++,mon=1;}
}
if(year>1582){
int run_nian=(year-1582)/400*3,yu_nian=((year-1582)%400)/100,yu=(year-1582)%100;
if(yu>18)yu_nian++;
yu_nian--;
run_nian+=yu_nian;
day-=run_nian;
}
if(year>=1582)
if(mon>=10)
if(day>=5)
day+=10;
if(year<=0)year--;
while(day>month[mon]){day-=mon;mon++;if(mon>12){mon-=12;year++;}}
cout<<day<<" "<<mon<<" "<<abs(year);
if(year<0)cout<<" "<<"BC"<<endl;else cout<<endl;
return ;
}
int main(){
int r,q;
cin>>r;
for(int i=1;i<=r;i++){
//cin>>q;
rl(i);//rl(q);
}
return 0;
}
就是这一段
int year=-4712,mon=1,day=1,month[]={29,31,28,31,30,31,30,31,31,30,31,30,31};
year+=q/1461;
for(int i=1;i<=q%1461;i++){
if(abs(year)%4==0){month[2]==29;}else {month[2]==29;}
day++;
if(day>month[mon]){day=1;mon++;cout<<month[mon]<<" ";}
if(mon>12){year++,mon=1;}
}