90分求助!!!
查看原帖
90分求助!!!
679634
riki1230楼主2023/6/10 21:43
#include <iostream>
using namespace std;
bool check(int x){
	for(int i=2;i<x;i++){
		if(x%i==0){
			return false;
		}
	}
	return true;
}
int a(int x){
	int b=0;
	while(x){
		b=b*10+x%10;
		x/=10;
   }
   return b;
}
int main(){
	int m,n,j=0;
	cin>>m>>n;
	for(int i=m;i<=n;i++){
		if(check(i)&&check(a(i))){
			j++;
			if(j==1){
				cout<<i;
				continue;
			}
			cout<<','<<i;
		}
	}
	
	return 0;
} 
2023/6/10 21:43
加载中...