momo36524 @ 2023-11-09 17:45:34
#include<stdio.h>
#include<math.h>
int check_if_is_prime(int n);
int check_if_is_palindromes(int n);
int main(void)
{
int min,max,i;
scanf("%d %d",&min,&max);
for(i=min;i<=max;i++)
if(check_if_is_prime(i)&&check_if_is_palindromes(i))
printf("%d\n",i);
return 0;
}
int check_if_is_prime(int n){
int i;
for(i=2;i<=sqrt(n);i++)
if(n%i==0&&i!=n)
return 0;
return 1;
}
int check_if_is_palindromes(int n){
int each_turn[9];
int sub_each_turn[9];
int i,k,counter;
for(i=0;n>0;i++){
if(n<10){
each_turn[i]=n;
n/=10;
}
else{
each_turn[i]=n%10;
n/=10;
}
}
i-=1;
counter=i;
for(k=0;i>=0;i--,k++)
sub_each_turn[k]=each_turn[i];
for(i=0,k=0;i<=counter;i++,k++)
if(sub_each_turn[k]!=each_turn[i])
return 0;
return 1;
}
by meowkesu @ 2023-11-09 18:26:24
@Ceceliaaaaa
by momo36524 @ 2023-11-11 10:58:09
@meowkesu 这是什么意思啊 有点没理解要看什么书吗 我是自学真的不太清楚ovo
by meowkesu @ 2023-11-11 12:37:04
@Ceceliaaaaa TLE-Time Limit Exceed 超出时间限制/超时。也就是说你的程序没有在规定时间内跑出答案(也就是超时)一样是错。