Created
November 8, 2016 21:08
-
-
Save xkrsz/6f0772f9251c58a5d9e0f0d0679d21ec to your computer and use it in GitHub Desktop.
Function checking if string is a palindrome
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
#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