-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5.12.cpp
83 lines (81 loc) · 1.73 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
73
74
75
76
77
78
79
80
81
82
83
// Xiaoyan Wang 12/25/2015
#include <iostream>
using namespace std;
int main() {
char ch;
int aCount = 0, eCount = 0, iCount = 0, oCount = 0, uCount = 0;
int spCount = 0, nlCount = 0, tbCount = 0;
int ffCount = 0, flCount = 0, fiCount = 0;
bool preIsF = false;
while(cin.get(ch)) {
switch(ch) {
case 'f':
case 'F':
if(!preIsF)
preIsF = true;
else
++ffCount;
break;
case 'a':
case 'A':
preIsF = false;
++aCount;
break;
case 'e':
case 'E':
preIsF = false;
++eCount;
break;
case 'i':
case 'I':
if(preIsF)
++fiCount;
preIsF = false;
++iCount;
break;
case 'o':
case 'O':
preIsF = false;
++oCount;
break;
case 'u':
case 'U':
preIsF = false;
++uCount;
break;
case ' ':
preIsF = false;
++spCount;
break;
case '\n':
preIsF = false;
++nlCount;
break;
case '\t':
preIsF = false;
++tbCount;
break;
case 'l':
case 'L':
if(preIsF)
++flCount;
preIsF = false;
break;
default:
preIsF = false;
break;
}
}
cout << "Number of vowel a: \t" << aCount << endl;
cout << "Number of vowel e: \t" << eCount << endl;
cout << "Number of vowel i: \t" << iCount << endl;
cout << "Number of vowel o: \t" << oCount << endl;
cout << "Number of vowel u: \t" << uCount << endl;
cout << "Number of spaces: \t" << spCount << endl;
cout << "Number of new lines: \t" << nlCount << endl;
cout << "Number of tabs: \t" << tbCount << endl;
cout << "Number of ff: \t" << ffCount << endl;
cout << "Number of fl: \t" << flCount << endl;
cout << "Number of fi: \t" << fiCount << endl;
return 0;
}