-
Notifications
You must be signed in to change notification settings - Fork 246
/
5.12.cpp
72 lines (70 loc) · 1.81 KB
/
5.12.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
int main() {
unsigned aCnt = 0, eCnt = 0, iCnt = 0, oCnt = 0, uCnt = 0;
unsigned spaceCnt = 0, tabCnt = 0, newlineCnt = 0, otherCnt = 0;
unsigned ffCnt = 0, flCnt = 0, fiCnt = 0;
bool fPresent = false;
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':
++iCnt;
break;
case 'i':
++iCnt;
if (fPresent) {
++fiCnt;
fPresent = false;
}
break;
case 'O': case 'o':
++oCnt;
break;
case 'U': case 'u':
++uCnt;
break;
case ' ':
++spaceCnt;
break;
case '\t':
++tabCnt;
break;
case '\n':
++newlineCnt;
break;
case 'f':
if (fPresent)
++ffCnt;
else
fPresent = true;
break;
case 'l':
if (fPresent) {
++flCnt;
fPresent = false;
}
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 sequence ff:\t" << ffCnt << '\n'
<< "Number of sequence fl:\t" << flCnt << '\n'
<< "Number of sequence fi:\t" << fiCnt << '\n'
<< "Number of others:\t" << otherCnt << std::endl;
return 0;
}