今天牛牛学到了回文串,他想在数字里面找回文,即回文数,回文数是正着读与倒着读都一样的数,比如1221,343是回文数,433不是回文数。请输出不超过n的回文数。
#include <stdio.h>
void Find(int x)
{
for(int i = 1;i<=x;i++)
{
int temp = 0,num=i;
while(num>0)
{
temp = temp * 10+num % 10;
num/=10;
}
if(temp==i)
{
printf("%d\n",temp);
}
}
}
int main() {
int n = 0;
scanf("%d",&n);
Find(n);
return 0;
}