Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <string>
- using namespace std;
- int main ()
- {
- string line;
- bool palindrome = false;
- while(getline(cin, line))
- {
- if (line == "DONE")
- break;
- for(int i = 0; i < line.size(); i++)
- {
- if((line[i] == 46) || (line[i] == 44) || (line[i] == 33) || (line[i] == 63) || (line[i] == 32))
- {
- line.erase(i, 1);
- i--;
- }
- }
- for(int j = 0; j < line.size(); j++)
- {
- int length = line.size() - 1;
- if((line[j] == line[length - j]) || (line[j] + 32 == line[length - j]) || (line[j] - 32 == line[length - j]))
- palindrome = true;
- else
- {
- palindrome = false;
- break;
- }
- }
- if(palindrome == true)
- cout << "You won't be eaten!" << endl;
- else
- cout << "Uh oh.." << endl;
- palindrome = false;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement