有没有大佬看看这个哪里错了,控制台的输出明明和答案是一模一样的
查看原帖
有没有大佬看看这个哪里错了,控制台的输出明明和答案是一模一样的
738720
Andy1216楼主2022/11/24 13:04
#include<iostream>
#include<cmath>
using namespace std;
bool isp(int x){
    if(x==0||x==1) return 0;
    for(int i=2;i*i<=x;i++){
        if(x%i==0)
        return 0;
    }
    return 1;
}
int main(){
    int f[20];
    int t=0;
    int x;
    int a;
    int b;
    int num;
    cin>>a>>b;
    if(a<=5) cout<<5<<endl;
    if(a<=7) cout<<7<<endl;
    if(a<=11) cout<<11<<endl;
    for(int i=10;i<10000;i++){
        x=i;
        while(1){
            f[t]=x%10;
            t+=1;
            x=x/10;
            if(x==0) break;
        }
        for(int j=1;j<t;j++){
            num+=f[j]*(pow(10,t-1-j)+pow(10,t-1+j));
        }
        num+=f[0]*pow(10,t-1);
        if(num>=a&&num<=b&&isp(num)){
            cout<<num<<endl;
        }
        t=0;
        num=0;
    }
    system("pause");
    return 0;   
}
2022/11/24 13:04
加载中...