【c语言】从键盘上输入一个5位十六进制整数,判断该十六进制数是否为回文数

坐等

第1个回答  2015-04-08
你可以参考下这个
#include<stdio.h>
#include<string.h>
int testPalintdorme(char x[]);
#define N 50
int main()
{
char x[N];
int T;
scanf("%d",&T);
while(T--)
{
scanf("%s",&x);
testPalintdorme(x);
printf("\n");
}
return 0;
}
int testPalintdorme(char x[])
{
int i,j;
j=0;
char y[N];
for(i=0;x[0]!='\0';i++)
j++;
for(i=j-1;i>=0;i--)
{
y[i]=x[i];
}
y[i]='\0';
if(strncmp(x,y,j)==0)
return true;
else
return false;
}
第2个回答  2015-04-08
#include"stdio.h"
#include"string.h"
int main()
{
char in[999];
int i,is=1,n;
scanf("%s",in);
n=strlen(in);
for(i=0;i<(n+1)/2;i++)
if(in[i]!=in[n-1-i])is=0;
if(is)printf("is");
else printf("not");
}本回答被网友采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网