It is necessary to leave the first 2 and remove all remaining repeats.
Example:
sky sky tec sky --- sky sky tec
y p y p y y p --- y p y p
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <boost/algorithm/string.hpp>
int main() {
std::string text;
std::cout<<"Enter string:\n";
getline(std::cin, text);
std::size_t const amount_to_remove = 2;
std::vector<std::string> tokens;
boost::split(tokens, text, boost::is_any_of(" .,"), boost::token_compress_on);
for (auto & token : tokens) {
boost::to_lower(token);
}
std::set<std::string> words(tokens.cbegin(), tokens.cend());
for (auto const& word : words) {
std::size_t count = std::count(tokens.cbegin(), tokens.cend(), word);
Here I stucked =(
if (count >= amount_to_remove)
{
//Remove Duplicates from the third repeated one
std::cout << text << std::endl;
}
Please, help:3 And if possible, add code.
Aucun commentaire:
Enregistrer un commentaire