chillurbrain

Task13_7_2

Dec 23rd, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <algorithm>
  3. #include <iostream>
  4. #include <string>
  5. #include <conio.h>
  6.  
  7. using namespace std;
  8.  
  9. bool isPalindrome(string line)
  10. {
  11.     for(int i = 0; i < line.length() / 2; i++)
  12.         if(line[i] != line[line.length() - i - 1]) return false;
  13.     return true;
  14. }
  15.  
  16. void clearSpaces(string& line)
  17. {
  18.     line.erase(std::remove(line.begin(), line.end(), ' '), line.end());
  19. }
  20.  
  21. int main()
  22. {
  23.     string line;
  24.     getline(cin, line);
  25.     clearSpaces(line);
  26.     if(isPalindrome(line))
  27.         cout << "yes";
  28.     else
  29.         cout << "no";
  30.     _getch();
  31.     return 0;
  32. }
Add Comment
Please, Sign In to add comment