fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool is_palindrome(const std::string &str) {
  5. bool result = true;
  6.  
  7. int i = 0;
  8. int j = str.size() - 1;
  9.  
  10. while(i < j) {
  11. if (toupper(str[i]) != toupper(str[j])) {
  12. result = false;
  13. break;
  14. }
  15. ++i;
  16. --j;
  17. }
  18.  
  19. return result;
  20. }
  21.  
  22. int main() {
  23. string str;
  24.  
  25. while(getline (cin, str)) {
  26. cout << (is_palindrome(str) ? "TAK": "NIE") << "\n";
  27. }
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 3472KB
stdin
test
kajak

a
Kajak
stdout
NIE
TAK
TAK
TAK
TAK