输入一个数字,判断是否是回文数,若是返回1,若不是返回0。
功能:
#include<string.h>
#include<stdio.h>
int huiwen(int n)
{
int i=0;
int end;
int begin;
int a[10];
while(n)
{
a[i++]=n%10;
n=n/10;
}
begin=0;
end=i-1;
while(begin<end)
{
if(a[begin]!=a[end])
return 0;
begin++;
end--;
}
return 1;
}
void main()
{
int n;
int result;
printf("please input the number:");
scanf("%d",&n);
result=huiwen(n);
if(result==1)
printf("%d is huiwen.\n",n);
else
printf("%d is not huiwen.\n",n);
}