C++中的绝对素数

#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cstring>
using namespace std;

bool su(int n){
    bool in=true;
    for(int j=2;j<n;j++){
        if(n%j==0){
            in=false;
        }
    }
    return in;
    
        
}

int main(){
    //绝对素数 
    int s=0;
    int ge,shi;
    for(int i=10;i<=99;i++){
        if(su(i)){
            ge=i%10;
            shi=i/10;
            s=ge*10+shi;
            if(su(s)){
                cout<<i<<endl;    
            }        
        }
    }
    return 0;
}
 

猜你喜欢

转载自blog.csdn.net/qq_37651894/article/details/97138388