Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. bool check_palindrome(const std::string &seq) {
  5. std::string::const_iterator forw_it = seq.begin();
  6. std::string::const_iterator bacw_it = seq.end();
  7. bacw_it--;
  8. while (forw_it < bacw_it) {
  9. if (*forw_it != *bacw_it) {
  10. return false;
  11. }
  12. forw_it++;
  13. bacw_it--;
  14. }
  15. return true;
  16. }
  17.  
  18. int main(int argc, char const *argv[])
  19. {
  20. /* code */
  21. std::string seq;
  22. std::getline(std::cin, seq);
  23. std::string::iterator bacw_it = seq.end();
  24. std::cout << check_palindrome(seq) << std::endl;
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement