LiJoQiao @ 2023-05-10 18:14:14
#include<cstdio>
using namespace std;
bool huiwen(int x)
{
if(x==0)
return true;
int len=0,tempx=x;
while(tempx!=0)
{
tempx/=10;
len++;
}
for(int i=1;i<=len/2;i++)
{
int l=x/((i-1)*10)%10,r=x/((len-i+1)*10)%10;
if(l!=r)
return false;
}
return true;
}
int main()
{
int a,b;
scanf("%d%d",&a,&b);
for(int i=a;i<=b;i++)
{
if(huiwen(i))
{
printf("%d\n",i);
}
}
return 0;
}
by LiJoQiao @ 2023-05-10 18:14:41
Runtime Error. Received signal 8: Floating-point exception.
by wangcaizsr @ 2023-05-10 19:51:06
除以零会RE
by Unreal414 @ 2023-05-10 21:38:01
@LiJoQiao
for(int i=1;i<=len/2;i++)
{
int l=x/((i-1)*10)%10,r=x/((len-i+1)*10)%10; //这里((i-1)*10)%10 = 0,除以0会RE
if(l!=r)
return false;
}
by LiJoQiao @ 2023-05-11 13:52:22
谢谢@wangcaizsr @Unreal414