-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5.11.cpp
More file actions
54 lines (51 loc) · 1.04 KB
/
5.11.cpp
File metadata and controls
54 lines (51 loc) · 1.04 KB
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
48
49
50
51
52
53
54
#include <iostream>
#include <string>
#include <cctype> // tolower
using std::string;
using std::cout;
using std::cin;
using std::endl;
int main() {
unsigned aCnt = 0, eCnt = 0, iCnt = 0, oCnt = 0, uCnt = 0;
unsigned spaceCnt = 0, tabCnt = 0, newlineCnt = 0;
string s;
while (getline(cin, s)) {
for (char ch : s) {
switch (tolower(ch)) {
case 'a':
++aCnt;
break;
case 'e':
++eCnt;
break;
case 'i':
++iCnt;
break;
case 'o':
++oCnt;
break;
case 'u':
++uCnt;
break;
case ' ':
++spaceCnt;
break;
case '\t':
++tabCnt;
break;
default:
break;
}
}
++newlineCnt;
}
cout << "Number of vowel a: " << aCnt << '\n'
<< "Number of vowel e: " << eCnt << '\n'
<< "Number of vowel i: " << iCnt << '\n'
<< "Number of vowel o: " << oCnt << '\n'
<< "Number of vowel u: " << uCnt << '\n'
<< "Number of spaces: " << spaceCnt << '\n'
<< "Number of tabs: " << tabCnt << '\n'
<< "Number of newlines: " << newlineCnt << endl;
return 0;
}