fork(1) download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. bool isPalindrome(const std::string &str) {
  5. return std::equal(str.cbegin(), str.cbegin() + (str.size() / 2), str.crbegin());
  6. }
  7.  
  8. int main() {
  9. std::cout << isPalindrome("kajak") << '\n'
  10. << isPalindrome("kobylamamalybok") << '\n'
  11. << isPalindrome("ala ma kota") << '\n'
  12. << isPalindrome("abba") << '\n';
  13. }
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
1
1
0
1