第三届“传智杯(练习赛)--E.儒略历

题目链接:儒略历

模拟就行了,注意看好闰年的规则,已掉坑

#include<bits/stdc++.h>
using namespace std;
int s1[13]={0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string s2[13]={"","JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"};
int istrue(int tmp)
{
	return tmp%4==0;
}
int isy(int tmp)
{
	return tmp%4==0&&(!(tmp%100==0&&tmp%400!=0));
}
int main()
{
	int d,m,y;
	string s;
	char a,b,c;
	scanf("%d%c%c%c%d",&d,&a,&b,&c,&y);
	s+=a;
	s+=b;
	s+=c;
	int t=0;
	int sum=0;
	for(int i=1;i<=y;i++)
	{
		
		for(int j=1;j<=12;j++)
		{
			if(i>=1582)
			t=(j==2&&isy(i))?1:0;
			else
			t=(j==2&&istrue(i))?1:0;
			
			for(int k=1;k<=s1[j]+t;k++)
			{
				if(i==1582&&s==s2[j]&&k==5)
				k=15;
				if(i==y&&s==s2[j]&&k==d)
				{
					cout<<sum<<endl;
					return 0;
				}
				sum++;
			}
						
		}
		
	}
}
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页