fork download
  1. #include <iostream>
  2. int main()
  3. {
  4. size_t words;
  5. std::cin >> words;
  6. bool* isPalindrome = new bool[words];
  7. for(int i = 0; i<words; ++i)
  8. {
  9. isPalindrome[i] = true;
  10. size_t length;
  11. std::cin >> length;
  12. char* word = new char[length+1];
  13. std::cin >> word;
  14. if(length == 1)
  15. {
  16. isPalindrome[i] = false;
  17. }
  18. else
  19. {
  20. for(int j = 0; j<length; ++j)
  21. {
  22. if(word[j] != word[length-j-1])
  23. {
  24. isPalindrome[i] = false;
  25. break;
  26. }
  27. }
  28. }
  29. }
  30. std::cout << "\n\n\n";
  31. for(int i = 0; i< words; ++i)
  32. {
  33. std::cout << "NIE\n\0TAK\n"+isPalindrome[i]*5;
  34. }
  35. }
  36.  
Success #stdin #stdout 0.01s 2816KB
stdin
4
2
ab
1
a
3
aba
9
aslkjfalk
stdout


NIE
NIE
TAK
NIE