#11没过怎么办?
查看原帖
#11没过怎么办?
658483
wanghan20100129楼主2022/10/9 21:31

代码如下

#include<bits/stdc++.h>
using namespace std;
int main(){
	int p,q,sum=0;
	cin>>p>>q;
	if(p==q){
		int tmp=0;
		tmp+=q/10000000;
		tmp+=q/1000000%10*10;
		tmp+=q/100000%10*100;
		tmp+=q/10000%10*1000;
		tmp+=q/1000%10*10000;
		tmp+=q/100%10*100000;
		tmp+=q/10%10*1000000;
		tmp+=q%10*10000000;
		if(tmp==p)sum=1;
	}else for(int i=p/10000;i<=q/10000+1;i++){
		int a=i*10000;
		a+=i%10*1000;
		a+=i/10%10*100;
		a+=i/100%10*10;
		a+=i/1000%10;
		int month=a%10000/100,day=a%100;
		if(month<=12&&month!=0&&day!=0){
			if(month==2){
				if(day<=29)sum++;
			}else if(day>30){
				if(day==31)
					if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
						if(a>=p&&a<=q)sum++;
			}else sum++;
		}
	}
	cout<<sum<<endl;
	return 0;
} 

大佬们帮一下吧

2022/10/9 21:31
加载中...