Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- bool check_palindrome(const std::string &seq) {
- std::string::const_iterator forw_it = seq.begin();
- std::string::const_iterator bacw_it = seq.end();
- bacw_it--;
- while (forw_it < bacw_it) {
- if (*forw_it != *bacw_it) {
- return false;
- }
- forw_it++;
- bacw_it--;
- }
- return true;
- }
- int main(int argc, char const *argv[])
- {
- /* code */
- std::string seq;
- std::getline(std::cin, seq);
- std::string::iterator bacw_it = seq.end();
- std::cout << check_palindrome(seq) << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement