Seal_of_approval

2p24

Nov 30th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int main(void)
  5. {
  6. string S;
  7. string S0;
  8. char C;
  9. cout << "Enter string S" << endl;
  10. getline(cin,S);
  11. cout << "Enter string S0" << endl;
  12. getline(cin,S0);
  13. cout << "Enter symbol" << endl;
  14. cin >> C;
  15. for (int i=0; i<S.length(); i++)
  16. if (S[i]==C)
  17. {
  18. S.insert(i+1,S0);
  19. i+=S0.length();
  20. }
  21. cout << "New string" << endl << S << endl;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment