Last active
February 25, 2017 01:14
-
-
Save mindthink/ef8bba4fd88a38240b561c210b6546e7 to your computer and use it in GitHub Desktop.
回文判断 ( 给定字符串,如何判断这个字符串是否是回文串)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
book IsPalindrome(const char *s,int n) | |
{ | |
//非法输入 | |
if(s == NULL || n < 1) | |
{ | |
return false; | |
} | |
const char* front,*back; | |
//初始化头指针和尾指针 | |
front= s; | |
back = s + n -1; | |
while(front <back) | |
{ | |
if(*front ! = *back) | |
( | |
return false; | |
) | |
++front; | |
--back; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
从两头往中间扫描