//用指针判断回文字符的程序:
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# define MAX 50
int cycle(char *s)
{
char *h,*t;
for(h=s,t=s+strlen(s)-1;t>h;h++,t--)
if(*h!=*t) break;
return t<=h;
}
main()
{
char s[MAX];
system("cls");
while(1)
{ puts("Please input the string you want to judge (input ^ to quit):");
scanf("%s",s); /*当输入的字符串的第一个字符是^时,退出*/
if(s[0]=='^')
break;
if(cycle(s))
printf(" %s is a cycle string./n",s);
else
printf(" %s is not a cycle string./n",s);
}
getch();
}
判断回文字符
最新推荐文章于 2020-11-25 08:37:40 发布