// Palindrome Tester #include #include #include using namespace std; string justLetters (string S) { string T; int N = S.size(); for (int i = 0; i <= N; i++) { if (isalpha(S[i])) T.push_back(tolower(S[i])); } return T; } bool isPalindrome (string phrase) { string S = justLetters(phrase); int N = S.size(); for (int X = 0; X <= N/2; X++) { if (S[X] != S[N-X-1]) { return false; } } return true; } int main () { if (isPalindrome ("wow")) cout << "'wow' is one\n"; if (isPalindrome ("bow")) cout << "'bow' is one\n"; string Adam = "Madam, I'm Adam."; string Napoleon = "Able was I ere I saw Elba."; string UTK = "University of Tennessee, Knoxville"; cout << "Letters in '" << Adam << "' = '" << justLetters(Adam) << "'\n"; if (isPalindrome(Adam)) cout << "'" << Adam << "' is one\n"; if (isPalindrome(Napoleon)) cout << "'" << Napoleon << "' is one\n"; if (!isPalindrome(UTK)) cout << "'" << UTK << "' is not one\n"; return 0; }