void biggies(std::vector<std::string>& s, std::string::size_type sz) { elimDups(s); stable_sort(s.begin(), s.end(), [](const std::string&a, const std::string&b ){return a.size()<b.size(); }); print(s); auto wc=std::partition(s.begin(), s.end(), [sz](const std::string& a)->int{return a.size()>=sz;}); for_each(s.begin(),wc,[](const std::string& s){std::cout<<s<<" "; }); std::cout<<std::endl; }
int main() { std::vector<int> vec = { 1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 5, 4, 3, 2, 1 }; elimDups(vec); std::cout << "after elimDups :\t"; for (auto &v : vec) { std::cout << v << " "; } std::cout << std::endl; return 0; }
void biggies(std::vector<std::string> &words, std::vector<std::string>::size_type st) { elimDups(words); stable_sort(words.begin(), words.end(), [](const std::string &a, const std::string &b) { return a.size() < b.size(); }); auto wc = find_if(words.begin(), words.end(), [st](const std::string &a) { return a.size() >= st; }); auto count = words.end() - wc; std::cout << count << " " << make_plural(count, "word", "s") << " of length " << st << " or longer" << std::endl; for_each(wc, words.end(), [](const std::string &s) { std::cout << s << " "; }); std::cout << std::endl; }