Advertisement
Pafnytiu

строки 2 - 7

Dec 22nd, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. setlocale(LC_ALL, "Russian");
  2. string sub, s;
  3. cout << "Введите строку 1: ";
  4. getline(cin,s);
  5. cout << "Введите строку 2: ";
  6. cin >> sub;
  7. string::size_type i = s.find(sub);
  8. /*string::size_type j = s.empty();
  9. if (j == s.empty())
  10. {
  11. s.erase(j,s.size());
  12. }*/
  13. for (int i = 0; i < s.length(); i++)
  14. {
  15. if (s[i] == ';' || s[i] == '!' || s[i] == ' ' || s[i] == ',' || s[i] == '.')
  16. { s.erase(i,1);}
  17. if (s.find(sub)==i)
  18. {
  19. s.erase(i,sub.size());
  20. }
  21. }
  22. cout << s << endl;
  23. system("pause");
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement