
用指针判断一个字符串是否为回文
1个回答
展开全部
int func(char *s)
{
char *p = s;
while(*p)p++;
p--;
while(*p == *s && p>s) p--,s++;
return p<=s;
int func(char *s)
{
char *p = s;
while(*p)p++;
p--;
while(*p == *s && p>s) p--,s++;
return p<=s;
}
int main()
{
char s[100];
scanf("%s",s);
if(func(s)) printf("%s是回文\n",s);
else printf("%s不是回文\n",s);
}
{
char *p = s;
while(*p)p++;
p--;
while(*p == *s && p>s) p--,s++;
return p<=s;
int func(char *s)
{
char *p = s;
while(*p)p++;
p--;
while(*p == *s && p>s) p--,s++;
return p<=s;
}
int main()
{
char s[100];
scanf("%s",s);
if(func(s)) printf("%s是回文\n",s);
else printf("%s不是回文\n",s);
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询