0
点赞
收藏
分享

微信扫一扫

031.判断字符串是否回文

大自然在召唤 2022-04-27 阅读 139
c语言
#include <stdio.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];
	clrscr();
	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);
	}
	puts("\nThank you for your using,bye bye!\n");
}
举报

相关推荐

0 条评论