fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. string s, x1, x2;
  4. int t, p = 0;
  5.  
  6. int main()
  7. {
  8. cin >> t;
  9. for(int i = 1; i <= t; i++)
  10. {
  11. getline(cin, s);
  12. cin.ignore();
  13. getline(cin, x1);
  14. cin.ignore();
  15. getline(cin, x2);
  16. cin.ignore();
  17. while(s.find(x1, p) != string::npos)
  18. {
  19. p = s.find(x1, p);
  20. s.replace(p, x1.size(), x2);
  21. p = p + x1.size();
  22. }
  23. cout << s << "\n";
  24. }
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.01s 5320KB
stdin
1
truc xinh truc moc dau dinh
dau dinh
bo ao
stdout