fork download
  1. #include <string>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. string str = "youareontheroadroadroadtohell";
  9. string road = "road";
  10. size_t road_pos = str.find(road);
  11. if (road_pos == string::npos)
  12. {
  13. cout << "NO";
  14. return 0;
  15. }
  16. else
  17. {
  18. string begin = str.substr(0, road_pos);
  19. string end = str.substr(road_pos + road.size());
  20. string result = begin + " " + road + " " + end;
  21. cout << result;
  22. }
  23. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
youareonthe road roadroadtohell