50求助,玄关
查看原帖
50求助,玄关
1036002
yjjh楼主2024/7/9 20:26
#include<bits/stdc++.h>
using namespace std;
int main(){
	int yueday[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int ans=0;
	string str1,str2;
	cin >>str1>>str2;
	for(int i=0;i<=3;i++)swap(str1[i],str1[7-i]);
	for(int i=0;i<=3;i++)swap(str2[i],str2[7-i]);
	while(str1!=str2){
		bool o=0;
		for(int i=0;i<=3;i++){
			if(str1[i]!=str1[7-i]){
				o=1;break;
			}
		}
		if(o==0)ans++;
		int year=(str1[7]-'0')*1000+(str1[6]-'0')*100+(str1[5]-'0')*10+(str1[4]-'0'),yue=(str1[3]-'0')*10+(str1[2]-'0'),day=(str1[1]-'0')*10+(str1[0]-'0');
		day++;str1[0]++;
		if(str1[0]==':')str1[1]++,str1[0]='0';
		if((year%4==0&&year%100!=0||year%400==0)&&yue==2&&day==30){
			str1[0]='0',str1[1]='0',str1[2]='3';yue++;
		}
		else if(day>yueday[yue]){
			str1[0]='0',str1[1]='0';
			str1[2]+=1;
			yue++;
			if(str1[2]==':')str1[2]='0',str1[3]++;
		}
		if(yue==13){
			str1[2]='0',str1[3]='0';
			str1[4]++;
			for(int i=4;i<=7;i++){
				if(str1[i]==':')str1[i+1]++,str1[i]='0';
			}
		}
	}
	cout <<ans;
	return 0;
}

2024/7/9 20:26
加载中...