Skip to content

Instantly share code, notes, and snippets.

@xkrsz
Created November 8, 2016 21:08
Show Gist options
  • Save xkrsz/6f0772f9251c58a5d9e0f0d0679d21ec to your computer and use it in GitHub Desktop.
Save xkrsz/6f0772f9251c58a5d9e0f0d0679d21ec to your computer and use it in GitHub Desktop.
Function checking if string is a palindrome
#include <iostream>
#include <string>
bool isPalindrome(std::string s) {
std::string p = "", f = "";
for(auto c:s) {
c = std::tolower(c);
int i = (int)c;
if(i > 96 && i < 123 || i > 47 && i < 58) {
f += c;
p = c + p;
}
}
return f == p;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment