#include <cstdio> #include <vector> #include <iostream> using namespace std; int main() { int n; vector<char> w; string s; scanf("%d", &n); char c; if (n != 0) { do { c = getc(stdin); } while (c == '\n' || isblank(c)); ungetc(c, stdin); for (int i = 0; i < n/2; ++i) { scanf("%c", &c); w.push_back(c); } if (n % 2) getchar(); for (int i = n/2-1; i >= 0; --i) { scanf("%c", &c); if (w[i] != c) { printf("NIE\n"); return 0; } } printf("TAK\n"); } else { cin >> s; for (int i = 0; i < s.size()/2; ++i) { if (s[i] != s[s.size()-i-1]) { printf("NIE\n"); return 0; } } printf("TAK\n"); } return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #include <cstdio> #include <vector> #include <iostream> using namespace std; int main() { int n; vector<char> w; string s; scanf("%d", &n); char c; if (n != 0) { do { c = getc(stdin); } while (c == '\n' || isblank(c)); ungetc(c, stdin); for (int i = 0; i < n/2; ++i) { scanf("%c", &c); w.push_back(c); } if (n % 2) getchar(); for (int i = n/2-1; i >= 0; --i) { scanf("%c", &c); if (w[i] != c) { printf("NIE\n"); return 0; } } printf("TAK\n"); } else { cin >> s; for (int i = 0; i < s.size()/2; ++i) { if (s[i] != s[s.size()-i-1]) { printf("NIE\n"); return 0; } } printf("TAK\n"); } return 0; } |