-
Notifications
You must be signed in to change notification settings - Fork 246
/
5.11.cpp
48 lines (46 loc) · 1.24 KB
/
5.11.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
48
#include <iostream>
int main() {
unsigned aCnt = 0, eCnt = 0, iCnt = 0, oCnt = 0, uCnt = 0;
unsigned spaceCnt = 0, tabCnt = 0, newlineCnt = 0, otherCnt = 0;
char ch;
while (std::cin.get(ch)) { // `<<` operator will omit whitespace characters
switch(ch) {
case 'A': case 'a':
++aCnt;
break;
case 'E': case 'e':
++eCnt;
break;
case 'I': case 'i':
++iCnt;
break;
case 'O': case 'o':
++oCnt;
break;
case 'U': case 'u':
++uCnt;
break;
case ' ':
++spaceCnt;
break;
case '\t':
++tabCnt;
break;
case '\n':
++newlineCnt;
break;
default:
++otherCnt;
}
}
std::cout << "Number of vowel a:\t" << aCnt << '\n'
<< "Number of vowel e:\t" << eCnt << '\n'
<< "Number of vowel i:\t" << iCnt << '\n'
<< "Number of vowel o:\t" << oCnt << '\n'
<< "Number of vowel u:\t" << uCnt << '\n'
<< "Number of space:\t" << spaceCnt << '\n'
<< "Number of tab:\t" << tabCnt << '\n'
<< "Number of newline:\t" << newlineCnt << '\n'
<< "Number of others:\t" << otherCnt << std::endl;
return 0;
}