Dan array of words. It is necessary to replace all the letters QQ in words with the letters BB. (For example, 4 words) After that, get a substring, taking two final letters from each array word longer than 1 character. To form a sentence from those array words that do not contain characters from the resulting substring. Rummaged through all the forums. Nothing helps. I tried to do through the initial stage through for_each, search, replace, find.
#include <iostream> #include <algorithm> #include <vector> #include <iterator> #include <string> using namespace std; void myfunction(string & i) { if (i == "QQ") i = "BB"; } int main() { vector<string> v; v.push_back("QQ"); v.push_back("creamQQ"); v.push_back("bQQbus"); v.push_back("cQQb"); v.push_back("QQcci"); ostream_iterator<string> printit(cout, " "); cout << "Before replacing" << endl; copy(v.begin(), v.end(), printit); for_each(v.begin(), v.end(), myfunction); cout << endl; cout << "After replacing" << endl; copy(v.begin(), v.end(), printit); cout << endl; system("pause"); return 0; }
And even somehow, and all for nothing = /