fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cctype>
  4.  
  5. bool isPalindrome(const std::string &str) {
  6. return std::equal(str.cbegin(),
  7. str.cbegin() + (str.size() / 2),
  8. str.crbegin(),
  9. [](char c1, char c2) {
  10. return (std::tolower(c1) == std::tolower(c2));
  11. });
  12. }
  13.  
  14. int main() {
  15. std::cout << isPalindrome("kaJAk") << '\n'
  16. << isPalindrome("koBylaMAMalyBOk") << '\n'
  17. << isPalindrome("ala Ma KoTa") << '\n'
  18. << isPalindrome("aBBa") << '\n';
  19. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
1
1
0
1