forked from Codecademy/learn-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
whale.cpp
47 lines (27 loc) · 761 Bytes
/
whale.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <vector>
#include <string>
int main() {
std::string input = "Turpentine and turtles.";
std::vector<char> vowels;
vowels.push_back('a');
vowels.push_back('e');
vowels.push_back('i');
vowels.push_back('o');
vowels.push_back('u');
std::vector<char> whale_talk;
for (int i = 0; i < input.size(); i++) {
for (int j = 0; j < vowels.size(); j++) {
if (input[i] == vowels[j]) {
whale_talk.push_back(input[i]);
if (input[i] == 'e' || input [i] == 'u') {
whale_talk.push_back(input[i]);
}
}
}
}
for (int k = 0; k < whale_talk.size(); k++) {
std::cout << whale_talk[k];
}
std::cout << "\n";
}