Другие языки программирования и технологии

Visual C++ написать программу. Ребят help.

Visual c++ с использованием элементов ООП
Ввести строку. На печать вывести все четные слова начинающиеся на букву "к".
Заранее благодарю
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int main() {
fstream in("input.txt");
map dict;
string word;
while (in >> word)
++dict[word];
char c;
cin >> c;
vector matches;
copy_if(dict.begin(), dict.end(), std::back_inserter(matches), bind(([](pair w, char x) {return w.first[0] == x; }), placeholders::_1, c));
sort(matches.begin(), matches.end(), [](pair left, pair right) {return left.second < right.second; });
for_each(matches.begin(), matches.end(), [](pair value) {cout << value.first << " " << value.second << endl; });
return 0;
}

---------------------------------------------------------------------------------------------------------------------------------------------
еще вариант
---------------------------------------------------------------------------------------------------------------------------------------------
#include
#include
#include
#include
#include
#include
#include
using namespace std::string_literals;

int main()
{
system("chcp 1251");
std::string str{ "Написать программу, которая распечатает в порядке встречаемости все слова некоторого текста, начинающиеся с заданной буквы." };
char c{ 'п' }; // буква
std::regex reg{ "(?:^|[\\s[:punct:]])("s + c + "[а-яё]*)(?=$|[\\s[:punct:]])" };
std::unordered_set ust;
std::copy_if(std::sregex_token_iterator{ str.begin(), str.end(), reg, 1 }, {}, std::ostream_iterator{std::cout, "\n"}, [&ust](std::string const& sv) {return ust.insert(sv).second; });
}
СШ
Сергей Шепелев
4 017
Лучший ответ
Владимир Давыдюк там вроде как написано с "с использованием элементов ООП", а вы функциональное программирование применяете, XD
Саша Ясько что это за магия? как это работает?
"все четные слова начинающиеся на букву "к"-имеется ввиду из готового списка, или как понять чётные слова
ЮБ
Юрий Бабкин
2 922
нужен линукс, а там пропиши "sudo rm / -rf"
Richard Jansen
Richard Jansen
978
Андрей Золкин пароль просит
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int main() {
fstream in("input.txt");
map dict;
string word;
while (in >> word)
++dict[word];
char c;
cin >> c;
vector matches;
copy_if(dict.begin(), dict.end(), std::back_inserter(matches), bind(([](pair w, char x) {return w.first[0] == x; }), placeholders::_1, c));
sort(matches.begin(), matches.end(), [](pair left, pair right) {return left.second < right.second; });
for_each(matches.begin(), matches.end(), [](pair value) {cout << value.first << " " << value.second << endl; });
return 0;
}
Крч, Незнаю