Skip to content

Instantly share code, notes, and snippets.

@ygabo
Created July 12, 2013 10:36
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 ygabo/5983455 to your computer and use it in GitHub Desktop.
Save ygabo/5983455 to your computer and use it in GitHub Desktop.
Check if palindrome
#include <iostream>
#include <string>
using namespace std;
bool is_pal( string x ){
int j = x.length()-1;
for( int i = 0; i < x.length()-1; ++i){
if( x[i] != x[j--]) return false;
}
return true;
}
int main(){
string d;
getline(cin, d);
cout << d << endl;
cout << is_pal(d) << endl;
cin.get();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment