Заменить каждую подстроку в тексте на другое слово или символ. Использовать вектор
Я попытался написать программу, но она не работает
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
using namespace std;
int cens(vector <string> text, vector <string> ban)
{
size_t n = text.size;
size_t m = ban.size;
for(size_t i = 0; i < n; i++)
{
for (size_t j = 0; j < m; j++)
{
if(text[i] == ban[j])
{
text[i] = "***";
j = 0;
}
}
}
return text;
}
void test()
{
vector <string> text =
{
"I begin my work with the time when Servius Galba was consul for the second time with Titus Vinius for his colleague.",
"Of the former period, the 820 years dating from the founding of the city, many authors have treated;",
"and while they had to record the transactions of the Roman people, they wrote with equal eloquence and freedom.",
"After the conflict at Actium, and when it became essential to peace, that all power should be centered in one man, these great intellects passed away."
}
vector <string> ban =
{
"beg",
"aut",
"record",
"zor"
}
cout << cens(text, ban) << endl;
}
int main()
{
test();
return 0;
}