shushus

Спринт 1. Алгоритм accumulate. Задание 2.

Dec 3rd, 2022
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <set>
  2. #include <string>
  3. #include <numeric>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. string TailStopWords (string res, const string& word){
  9.     return res+="-"s+word+" ";
  10. }
  11.  
  12. string AddStopWords(const string& query, const set<string>& stop_words) {
  13.      if (stop_words.empty()){
  14.         return query;
  15.     }
  16.     string str = accumulate(stop_words.begin(), stop_words.end()," "s, TailStopWords);
  17.     return query+str;
  18. }
  19.  
  20. int main(){
  21.     string query = "some tasty oranges";
  22.     set<string> stop_words = {"of", "in"};
  23.     cout<<AddStopWords(query, stop_words)<<endl;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment