Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions homework/remove-vowels/vowel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "vowel.hpp"
#include <algorithm>
#include <string>

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<std::string>& data) -> void {
for (auto& str : data) {
for (auto chr : VOWELS) {
removeChar(str, chr);
}
}
}
11 changes: 11 additions & 0 deletions homework/remove-vowels/vowel.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once
#include <array>
#include <string>
#include <vector>

inline constexpr std::array<const char, 12> 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<std::string>& data) -> void;