#include <iostream>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main()
{int k=0,t=1,a[20],num,i=0;
printf("请输入一个数字");
scanf("%d",&num);
int n=num;
for(;n!=0;i++)
{a[i]=n%10;
n/=10;
} /*完成数据的储存*/
for(;i>=1;i--)
{k+=a[i-1]*t; /*t为权重*/
t*=10;
}
if(k==num)
printf("是回文数");
else printf("不是回文数");
system("pause");
}
判断回文数
最新推荐文章于 2024-07-18 15:18:05 发布