diff --git a/homework/remove-vowels/vowel.cpp b/homework/remove-vowels/vowel.cpp new file mode 100644 index 000000000..b13a777f0 --- /dev/null +++ b/homework/remove-vowels/vowel.cpp @@ -0,0 +1,17 @@ +#include "vowel.hpp" +#include +#include + +auto removeChar(std::string& data, const char c) -> void { + while (data.find(c) < data.size()) { + data.erase(data.begin() + data.find(c)); + } +} + +auto removeVowels(std::vector& data) -> void { + for (auto& str : data) { + for (auto chr : VOWELS) { + removeChar(str, chr); + } + } +} diff --git a/homework/remove-vowels/vowel.hpp b/homework/remove-vowels/vowel.hpp new file mode 100644 index 000000000..5869bfc55 --- /dev/null +++ b/homework/remove-vowels/vowel.hpp @@ -0,0 +1,11 @@ +#pragma once +#include +#include +#include + +inline constexpr std::array VOWELS{ + 'A', 'E', 'I', 'O', 'U', 'Y', 'a', 'e', 'i', 'o', 'u', 'y'}; + +auto removeChar(std::string& data, const char c) -> void; + +auto removeVowels(std::vector& data) -> void;