# include<stdio.h>
int main(void)
{
int sum = 0, val, m;
printf("请输入一个随机整数:");
scanf("%d",&val);
m=val;
while (m){
sum= sum*10 + m%10;//(理解举例:m==123,sum==3*10^2 + 2*10^1 +3*10^0)
m/= 10;
}
if (sum == val){
printf("%d是回文数",val);
}else
{
printf("%d不是回文数",val);
}
return 0;
}
时间: 2024-10-13 02:27:28