判斷迴文串,迴文串
/********************************************************************** * Copyright (c)2015,WK Studios * Filename: * Compiler: GCC,VS,VC6.0 win32 * Author: WK * Time: 2015 4 3 ************************************************************************/ #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')//使C指標指向最後一個字元'\0'{NULL;}while(temp < c){if(*temp++ != *--c)return false;}return true;}int main(){char a[]="abcba";if( isPalindromeChar(a))//判斷迴文字串//if(isPalindromeNumber(12321))//判斷迴文數字{cout<<"hahahahahaha,successful"<<'\n';} else{cout<<"enenenenenen,false"<<'\n';}system("pause");return 0;}