Advertisement
VictoriaLodochkina

lab 4 z3 WITHOUT QT!!!

Mar 12th, 2020
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. using namespace std;
  5. int main()
  6. {
  7.     cout << "Enter text: " << endl;
  8.     string text, word;
  9.     getline(cin, text);
  10.     stringstream s(text);
  11.    while (s >> text)
  12.    {
  13.        int len = text.length();
  14.        if (ispunct(text.at(len - 1)))
  15.        {
  16.            len--;
  17.        }
  18.        char symbol = text.at(len - 1);
  19.      
  20.        int poz = 0;
  21.         for (int i = 0; i < len - 2; i++)//-2 or -1
  22.         {
  23.             int posit;
  24.             posit = text.find(symbol, poz);
  25.             if ((posit>=0)&&(posit!=len-1))
  26.             {
  27.                 poz += posit + 1;///
  28.                 text.replace(posit, 1, "+");
  29.             }
  30.             else break;
  31.         }
  32.     }
  33.    cin.ignore(100, '\n');
  34.    cin.clear();
  35.    cout << text;
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement