#include #include #include using namespace std; bool IsPalindrome(string word); int main() { vector words = {"able was i ere i saw elba", "race car", " a", "bad one", " b a d o n e ", "AbLe was I ere I saw elba.", "No Pal Of Mine ENIm fO LAp On"}; string phrase; int i; for(i = 0; i < words.size();i++) { phrase = words[i]; cout << phrase << " is " ; if (!IsPalindrome(phrase)) { cout << "not "; } cout << "a palindrome" << endl; } return 0; } bool IsPalindrome(string word){ int i,j; i = 0; j = word.size()-1; while(i < j) { while (i <= j and not isalpha(word[i])) { i++; } while (i <= j and not isalpha(word[j])) { j--; } if (i < j) { if (toupper(word[i]) != toupper(word[j])) { return false; } else { i++; j--; } } } return true; }