Advertisement
Guest User

^^

a guest
Dec 14th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include<fstream>
  2. #include<string>
  3. #include<map>
  4. #include<algorithm>
  5. using namespace std;
  6.  
  7. int main() {
  8.     string start, finish;
  9.     ifstream fileIn;
  10.     ofstream fileOut;
  11.     fileIn.open("input.txt");
  12.     fileOut.open("output.txt");
  13.     getline(fileIn, start);
  14.     getline(fileIn, finish);
  15.     map<char, char> symbs;
  16.     for (size_t i = 0; i < start.size(); ++i) {
  17.         symbs[start[i]] = finish[i];
  18.     }
  19.     string line;
  20.     while (getline(fileIn, line)) {
  21.         int cnter = 0;
  22.         for (char x : line) {
  23.             if (symbs.find(x) != symbs.end()) {
  24.                 line[cnter] = symbs[x];
  25.             }
  26.             ++cnter;
  27.         }
  28.         fileOut << line <<"\n";
  29.     }
  30.     fileIn.close();
  31.     fileOut.close();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement