266
Enunt eliminat la cererea autorului.
Exemplul 1:
polybius.in
1 ABCDEFGHIKLMNOPQRSTUVWXYZ ANAAREMERE
polybius.out
11331111421532154215
Exemplul 2:
polybius.in
2 ABCDEFGHIKLMNOPQRSTUVWXYZ 11331111421532154215
polybius.out
ANAAREMERE
#include <bits/stdc++.h> using namespace std; ifstream cin("polybius.in"); ofstream cout("polybius.out"); char mat[6][6]; int cer; int main() { cin >> cer; char a[30]; cin >> a; int k = 0; for(int i = 1; i <= 5; ++i) for(int j = 1 ; j <= 5; ++j){ while(a[k] == ' ') k++; mat[i][j] = a[k]; k++; } cin.get(); int X[30]; if(cer == 2){ char a, b; while(cin >> a >> b) cout << mat[a-'0'][b-'0']; } else{ char ch; for(int i = 1 ; i <= 5; ++i) for(int j = 1 ; j <= 5; ++j) X[mat[i][j]-'A'] = i * 10 + j; while(cin >> ch) cout << X[ch-'A']; } return 0; }
Comentarii