Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <algorithm>
- #include <iostream>
- #include <string>
- #include <conio.h>
- using namespace std;
- bool isPalindrome(string line)
- {
- for(int i = 0; i < line.length() / 2; i++)
- if(line[i] != line[line.length() - i - 1]) return false;
- return true;
- }
- void clearSpaces(string& line)
- {
- line.erase(std::remove(line.begin(), line.end(), ' '), line.end());
- }
- int main()
- {
- string line;
- getline(cin, line);
- clearSpaces(line);
- if(isPalindrome(line))
- cout << "yes";
- else
- cout << "no";
- _getch();
- return 0;
- }
Add Comment
Please, Sign In to add comment