#include <iostream> #include <cstdio> #include <cmath> #include <string> #define MAX_LEN 2000000 using namespace std; int main() { int n = 0; int size; scanf("%d\n", &size); n = size; if (size == 0) size = MAX_LEN; char signs[size]; if (n > 0) { for (int i = 0; i < n; ++i) { scanf("%c", &signs[i]); } } else { char c; scanf("%c", &c); while (c != '\n') { signs[n] = c; n++; scanf("%c", &c); } } for (int i = 0; i < n / 2; i++) { if (signs[i] != signs[n - i - 1]) { cout << "NIE" << endl; return 0; } } cout << "TAK" << endl; 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 | #include <iostream> #include <cstdio> #include <cmath> #include <string> #define MAX_LEN 2000000 using namespace std; int main() { int n = 0; int size; scanf("%d\n", &size); n = size; if (size == 0) size = MAX_LEN; char signs[size]; if (n > 0) { for (int i = 0; i < n; ++i) { scanf("%c", &signs[i]); } } else { char c; scanf("%c", &c); while (c != '\n') { signs[n] = c; n++; scanf("%c", &c); } } for (int i = 0; i < n / 2; i++) { if (signs[i] != signs[n - i - 1]) { cout << "NIE" << endl; return 0; } } cout << "TAK" << endl; return 0; } |