Advertisement
Miogarun

Untitled

Mar 15th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3. #include <algorithm>
  4.  
  5. bool poli_test(std::string s){
  6.     std::string buf = s;
  7.     std::reverse(s.begin(), s.end());
  8.     if (buf == s) return true;
  9.     return false;
  10. }
  11.  
  12. int main(){
  13.     std::string s;
  14.     std::getline(std::cin, s);
  15.  
  16.     s += ' ';
  17.  
  18.     int k = 0;
  19.  
  20.     while (true){
  21.         while (s[0] == ' ') s.erase(0, 1);
  22.         if (s.empty()) break;
  23.         if (poli_test(s.substr(0, s.find(' ')))) k += 1;
  24.         s.erase(0, s.find(' ') + 1);
  25.     }
  26.     std::cout << k;
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement