Advertisement
VictoriaLodochkina

lab 4 z1 MORE FUNCTIONS

Mar 17th, 2020
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     string text, word;
  9.     string symbol;
  10.     cout << "Enter symbol: " << endl;
  11.     getline(cin, symbol);
  12.     symbol.resize(1);//чтобы было больше функций
  13.     cout << "Enter text: " << endl;
  14.     getline(cin, text);
  15.     stringstream words(text);
  16.     while (words >> word)
  17.     {
  18.         bool flag = 0;
  19.         for (int i = 0; i < word.length(); i++)//еще больше функций
  20.         {
  21.             if (word.find(symbol) != string::npos)
  22.             {
  23.                 flag = 1;;
  24.             }
  25.         }
  26.         if (flag)
  27.         {
  28.             cout << word << endl;
  29.         }
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement