10pts求助 所有民间数据都没有挂成这样
查看原帖
10pts求助 所有民间数据都没有挂成这样
93266
断清秋楼主2020/11/18 11:50
#include<bits/stdc++.h>
#define ll long long
#define back return 
#define ri register int
using namespace std;
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},month1[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int month1582[13]={0,31,28,31,30,31,30,31,31,30,21,30,31};
// run month1
int q,r,year=-4713,day=1,mon=1;
void print()
{
	if(year>0)
	{
		cout<<day<<" "<<mon<<" "<<year<<endl;
		day=1,mon=1,year=-4713;
		back ;
	}
	else
	{
		cout<<day<<" "<<mon<<" "<<abs(year)<<" "<<"BC"<<endl;
		day=1,mon=1,year=-4713;
		back ;
	}
}
void ping()
{
	for(ri i=1;i<=12;i++)
	{
		if(r>=month[i])
		{
			r-=month[i];
			mon++;
		}
		else
		{
			day+=r;
			print();
			back ;
		}
	}
}
void run()
{
	for(ri i=1;i<=12;i++)
	{
		if(r>=month1[i])
		{
			r-=month1[i];
			mon++;
		}
		else
		{
			day+=r;
			print();
			back ;
		}
	}
}
void year1582()
{
	for(ri i=1;i<=12;i++)
	{
		if(r>=month1582[i])
		{
			r-=month1582[i];
			mon++;
		}
		else
		{
			day+=r;
			if(mon==10)
				day+=10;
			print();
			back ;
		}
	}
}
int main()
{
	//freopen("julian.in","r",stdin);
	//freopen("julian.out","w",stdout);
	cin>>q;
	while(q--)
	{
		cin>>r;
		while(1)
		{
			while(r>=366)
			{
				if(year<1582)
				{
					if(year==0)
						year++;
					if(year<0)
					{
						if((year-4*year)%4!=3)
						{
							r-=365;
							year++;
						}
						else
						{
							r-=366;
							year++;
						}
					}
					else
					{
						if(year%4!=0)
						{
							r-=365;
							year++;
						}
						else
						{
							r-=366;
							year++;
						}
					}
				}
				else if(year==1582)
				{
					if(r>=355)
					{
						r-=355;
						year++;
					}
						
					else
					{
						year1582();
						break;
					}	
				}
				else
				{
					if((year%4==0&&year%100!=0)||year%400==0)
					{
						r-=366;
						year++;
					}
					else
					{
						r-=365;
						year++;
					}
				}
			}
			if(year<1582)
			{
				if(year<0)
				{
					if((year-4*year)%4!=3)
					{
						ping();
						break;
					}
					else
					{
						run();
						break;
					}
				}
				else
				{
					if(year%4!=0)
					{
						ping();
						break;
					}
					else
					{
						run();
						break;
					}
						
				}
			}
			if(year>1582)
			{
				if((year%4==0&&year%100!=0)||year%400==0)
				{
					run();
					break;
				}
				else
				{
					ping();
					break;
				}
			}
		}
	}
	back 0;
}

当然这份代码有很多问题 比如特判10.4的时候,但是为什么在第二个点就会错?

2020/11/18 11:50
加载中...