Skip to content

Instantly share code, notes, and snippets.

@mindthink
Last active February 25, 2017 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindthink/ef8bba4fd88a38240b561c210b6546e7 to your computer and use it in GitHub Desktop.
Save mindthink/ef8bba4fd88a38240b561c210b6546e7 to your computer and use it in GitHub Desktop.
回文判断 ( 给定字符串,如何判断这个字符串是否是回文串)
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;
}
@mindthink
Copy link
Author

从两头往中间扫描

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment