Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C语言 判断回文数为什么超过5位数就判断不了?
C语言 判断回文数为什么超过5位数就判断不了?
/*超过5位整型就溢出了,你把接收的整形数当作字符串来处理就好了,这样多少位不限,通吃*/

/*可输入1位*/

# include & lt;stdio.h & gt# define MAX 1 int HW(char s[])

{

/* int m = ,v = n;while(v & gt;)

{

m = m * 1+v % 1;v/= 1;return(m = = n);*/

int i,j;int n = strlen(s);

for (i = ,j = n-1;我& ltn/2+1;i++,j - )

{

if (s[i]!= s[j])

{

break;}

}

if (i == n/2+1)

{

返回1;}

else

{

返回;}

}

main()

{

int b;

char s[MAX];

printf("输入一个整数:");

scanf("%s ",s);b =硬件(s);if(b)

printf(" YES ");else printf(" NO ");

}