码迷,mamicode.com
首页 > 其他好文 > 详细

判断回文串

时间:2015-04-03 17:23:49      阅读:97      评论:0      收藏:0      [点我收藏+]

标签:

#include<iostream>
using namespace std;
#include<assert.h>

bool isPalindromeNumber(long num)
{
	if(num<0)
		return false;
	long temp=num;
	long y=0;
	while(temp)
	{
		y=y*10+temp%10;
		temp/=10;
	}

	return num==y;

	return false;
}


bool isPalindromeChar(char *c)
{
	assert(c!=NULL);
	char *temp=c;
	while(*++c!='\0')
	{
		NULL;
	}
	while(temp < c)
	{
		if(*temp++ != *--c)
			return false;
	}
	return true;
}
int main()
{

	char a[]="abcba";
	if( isPalindromeChar(a))
	{
		cout<<"hahahahahaha,successful"<<'\n';
	}    
	else
	{
		cout<<"enenenenenen,false"<<'\n';
	}
	system("pause");

	return 0;
}

判断回文串

标签:

原文地址:http://blog.csdn.net/kai8wei/article/details/44857217

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!