Advertisement
elephantsarecool

ripduckduck

Jan 18th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. using namespace std;
  5. string star(int n)
  6. {
  7.     string answer;
  8.     while(--n)
  9.         answer+='*';
  10.     answer+=' ';
  11.     return answer;
  12. }
  13. int main()
  14. {
  15.     vector <string> k;
  16.     string sentence;
  17.     int quantity;
  18.     cin >> quantity;
  19.  
  20.     for (int i = 0; i < quantity; ++i)
  21.     {
  22.         string word;
  23.         cin >> word;
  24.         word+=' ';
  25.         k.push_back(word);
  26.     }
  27.     cin.ignore();
  28.     getline(cin, sentence);
  29.     sentence+=' ';
  30.     for (int i = 0; i < k.size(); ++i)
  31.     {
  32.              string astgh=star(k[i].length());
  33.              while(sentence.find(k[i])!=string::npos)
  34.                     sentence.replace(sentence.find(k[i]),k[i].length(),astgh);
  35.     }
  36.     cout << sentence;
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement