#include <iostream> #include <cstdlib> #include <cmath> #include <string> #include <stdio.h> using namespace std; int main() { int x, wyn = 0; string a, b; cin >> x >> a >> b; for (int i = 0; i < x; i++) { for (int j = 0; j < x-1; j++) { if (b[j] > b[j + 1]) swap(b[j], b[j + 1]); } if (a[x-i] == b[x-i]) { wyn++; } else { break; } } if(wyn == x){ cout << "TAK"; } else { cout << "NIE"; } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <iostream> #include <cstdlib> #include <cmath> #include <string> #include <stdio.h> using namespace std; int main() { int x, wyn = 0; string a, b; cin >> x >> a >> b; for (int i = 0; i < x; i++) { for (int j = 0; j < x-1; j++) { if (b[j] > b[j + 1]) swap(b[j], b[j + 1]); } if (a[x-i] == b[x-i]) { wyn++; } else { break; } } if(wyn == x){ cout << "TAK"; } else { cout << "NIE"; } } |