c10分求救

题目总版

zhouph @ 2024-11-08 15:11:43


#include<stdio.h>
int isprime(int a);
int is(int a);
int main()
{
    int n,m,i,j=1;
    scanf("%d %d",&n,&m);
    for(i=n;i<m;i++){
        if(is(i)){
            printf("%d,",i);
            j=0;
        }
    }
    if(is(m)){
        printf("%d",m);
        j=0;
    }
    if(j)printf("No");
    return 0;
}
int isprime(int a)
{
    int i;
    if(a<=1)return 0;
    if(a==2||a==3)return 1;
    if(a%2==0||a%3==0)return 0;
    for(i=5;i*i<=a;i+=6){
        if(a%i==0||a%(i+2)==0)return 0;
    }
    return 1;
}
int is(int a)
{
    int i=a,j,k=0;
    do{
        j=i%10;
        i/=10;
        k=k*10+j;
    }while(i>0);
    if(isprime(a)&&isprime(k))return 1;
    else return 0;
}

by HgSO4_QwQ @ 2024-11-08 15:40:28

哪道题


|