Skip to content

Instantly share code, notes, and snippets.

@pinglunliao
Last active November 5, 2019 08:34
Show Gist options
  • Save pinglunliao/76729dc0358d3a1976d6 to your computer and use it in GitHub Desktop.
Save pinglunliao/76729dc0358d3a1976d6 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
void msg(bool b);
bool isPalindrome( const string &s );
int main()
{
string str;
while(cin >> str)
{
msg(isPalindrome(str));
}
return 0;
}
void msg(bool b)
{
cout << (b?"yes":"no") << endl;
}
bool isPalindrome( const string &s )
{
short len = s.length();
for(short i = 0; i < len / 2; i++)
{
if( s[i] != s[len - 1 - i] )
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment