Advertisement
Dzham

Untitled

Dec 12th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #include <vector>
  5. #include <set>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10. string str, rep, sub, line;
  11. getline(cin, sub);
  12. getline(cin, rep);
  13. vector<string> result;
  14. vector<char> v1(sub.begin(), sub.end());
  15. set<char> st(sub.begin(), sub.end());
  16. vector<char> v2(rep.begin(), rep.end());
  17. while (getline(cin, line)) {
  18. vector<char> v(line.begin(), line.end());
  19. for (int i = 0; i < v.size(); i++) {
  20. if (st.find(v[i]) != st.end()) {
  21. size_t p = find(v1.begin(), v1.end(), v[i]) - v1.begin();
  22. line.replace(i, 1, string(1, v2[p]));
  23. }
  24. }
  25. result.push_back(line);
  26. }
  27. for (string s : result) {
  28. cout << s << '\n';
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement