#include <iostream>
#include <cctype>
#include <string>
Go to the source code of this file.
◆ main()
Definition at line 6 of file checkpoint6.7.cpp.
6 {
7 string input;
8 getline(cin, input);
9 for (unsigned int i = 0; i < input.length(); i++){
10 if (!isalpha(input[i])){
11 input.erase(i, 1);
12 i--;
13 }
14 }
15
16 bool isPalindrome = true;
17
18 for (unsigned int i = 0; i < input.length() / 2; i++){
19
20 if (tolower(input[i]) != tolower(input[input.length() - 1 - i])){
21 isPalindrome = false;
22
23 break;
24 }
25 }
26 cout << "The input string is " << (isPalindrome ? "" : "not " ) << "a palindrome." << endl;
27 return 0;
28}