Advertisement
tobast

Untitled

Feb 8th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. //Code utile
  7. bool checkPalin(const string& str)
  8. {
  9.     size_t begin=0, end=str.size()-1;
  10.     while(begin < end)
  11.     {
  12.         if(str[begin] != str[end])
  13.             return false;
  14.         begin++;
  15.         end--;
  16.     }
  17.     return true;
  18. }
  19. //Fin code utile
  20.  
  21. int main(void)
  22. {
  23.     string rawtitle, title;
  24.     getline(cin, rawtitle);
  25.  
  26.     //Debut code utile
  27.     for(size_t pos=0; pos < rawtitle.size(); pos++)
  28.         if(rawtitle[pos] != ' ')
  29.             title.push_back(tolower(rawtitle[pos]));
  30.     //Fin code utile
  31.  
  32.     if(checkPalin(title))
  33.         cout << "1\n";
  34.     else
  35.         cout << "0\n";
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement