字符串:用指针判断一个字符串是否为回文串。

#include<stdio.h>
#include<string.h>
int huiWen(char *p)
{
	char *s,*e;
	int len=strlen(p);
	s=p;//地址赋值 
	e=p+len-1;
	while(*s==*e&&s<e)
	{
		s++;//地址移动 
		e--;
	}
	if(s<e){
		return 0;
	}else{
		return 1;
	}
}
int main()
{
	char p[20];
	int leap;
	gets(p);
	leap=huiWen(p);
	if(leap){
		printf("是回文!"); 
	} else{
		printf("不是回文!"); 
	}
	return 0;
}
全部评论

相关推荐

牛客773130651号:巨佬,简历模板换成上下的,左右的很烦,hr看着不爽。。。科大随便乱杀,建议能保研就保研,不行也得考一下 ,985硕去干算法,比开发强多了。开发许多双非都能搞,学历优势用不上,算法有门槛
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务