您的位置:首页 > 其它

判断回文字符

2010-07-11 16:26 127 查看
//用指针判断回文字符的程序:
# 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();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐