fork(1) download
  1. #include <iostream>
  2. #include <cassert>
  3.  
  4. using namespace std;
  5.  
  6. string GaDeRy(string s, const string &szyfr) {
  7. assert(szyfr.size()%2==0);
  8.  
  9. for(int i = 0; i < s.size(); i++ ) {
  10. size_t j = szyfr.find(s[i]);
  11. if (string::npos!=j) {
  12. s[i] = szyfr[j^1];
  13. }
  14. }
  15. return s;
  16. }
  17.  
  18. int main() {
  19. string kod, s;
  20. cin >> kod >> ws;
  21. while(getline(cin, s)) {
  22. cout << GaDeRy(s, kod) << endl;
  23. }
  24. return 0;
  25. }
Success #stdin #stdout 0s 3436KB
stdin
GADERYPOLUKIgaderypoluki
ABCD
GBCE
stdout
GBCE
ABCD