#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;
int main()
{
char str[] = "Все не так уж важно";
char *token = strtok(str, " ");
char new_str[100] = "";
while (token != NULL)
{
if (isalpha(token[0]) && !strchr("aeiouyAEIOUY", token[0]))
{
// слово начинается на согласную букву
}
else
{
// слово начинается на гласную букву
strcat(new_str, token);
strcat(new_str, " ");
}
token = strtok(NULL, " ");
}
cout << new_str << endl;
return 0;
}
#include <iomanip> #include <iostream> #include <string> #include <vector> std::string remove_word_by_first(const std::string s, const std::string first) { std::string::size_type n; std::string::size_type e; std::string result=" "; result+=s; while ((n = result.find(first)) != std::string::npos) { e = result.find(" ", n+1); result.replace(n, e-n, ""); } result.erase(0,1); return result; } int main() { const std::string example = "you can build shelves for every room in your home and custom-make them after your needs"; std::vector<std::string> key_list; key_list.push_back(" a"); key_list.push_back(" e"); key_list.push_back(" i"); key_list.push_back(" o"); key_list.push_back(" u"); key_list.push_back(" y"); std::string s = example; for (auto a: key_list) { s = remove_word_by_first(s, a); } std::cout << s <<std::endl; return 0; }