Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <set>
- #include <string>
- #include <numeric>
- #include <iostream>
- using namespace std;
- string TailStopWords (string res, const string& word){
- return res+="-"s+word+" ";
- }
- string AddStopWords(const string& query, const set<string>& stop_words) {
- if (stop_words.empty()){
- return query;
- }
- string str = accumulate(stop_words.begin(), stop_words.end()," "s, TailStopWords);
- return query+str;
- }
- int main(){
- string query = "some tasty oranges";
- set<string> stop_words = {"of", "in"};
- cout<<AddStopWords(query, stop_words)<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment