#include <stdio.h> int n; int bit_niep[26],bit_parz[26],baj_niep[26],baj_parz[26]; int main() { char z; int i,f; scanf("%d\n",&n); for(i=0;i<n;++i) { if(i==n-1) scanf("%c\n",&z); else scanf("%c",&z); if(i%2) (bit_niep[z-'a'])++; else (bit_parz[z-'a'])++; } for(i=0;i<n;++i) { scanf("%c",&z); if(i%2) (baj_niep[z-'a'])++; else (baj_parz[z-'a'])++; } f=1; for(i=0;i<26;++i) if((bit_niep[i]!=baj_niep[i]) || (bit_parz[i]!=baj_parz[i])) f=0; if(f) printf("TAK\n"); else printf("NIE\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 | #include <stdio.h> int n; int bit_niep[26],bit_parz[26],baj_niep[26],baj_parz[26]; int main() { char z; int i,f; scanf("%d\n",&n); for(i=0;i<n;++i) { if(i==n-1) scanf("%c\n",&z); else scanf("%c",&z); if(i%2) (bit_niep[z-'a'])++; else (bit_parz[z-'a'])++; } for(i=0;i<n;++i) { scanf("%c",&z); if(i%2) (baj_niep[z-'a'])++; else (baj_parz[z-'a'])++; } f=1; for(i=0;i<26;++i) if((bit_niep[i]!=baj_niep[i]) || (bit_parz[i]!=baj_parz[i])) f=0; if(f) printf("TAK\n"); else printf("NIE\n"); return 0; } |