-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExer05_11.cpp
57 lines (57 loc) · 1.49 KB
/
Exer05_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
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <cctype>
using std::cout;
using std::cin;
using std::endl;
int main()
{
unsigned aCnt = 0, eCnt = 0, iCnt = 0, oCnt = 0, uCnt = 0;
unsigned blkCnt = 0, tabCnt = 0, nlCnt = 0;
char ch;
while(cin.get(ch))// Here we use some out-of-scope function to read black
// tab and newline.
{
switch(ch){
case 'a':
case 'A':
++aCnt;
break;
case 'e':
case 'E':
++eCnt;
break;
case 'i':
case 'O'
++iCnt;
break;
case 'o':
case 'O':
++oCnt;
break;
case 'u':
case 'U':
++uCnt;
break;
case ' ':
++blkCnt;
break;
case '\t':
++tabCnt;
break;
case '\n':
++nlCnt;
break;
default:
break;
}
}
cout << "Number of vowel a: \t" << aCnt << endl;
cout << "Number of vowel e: \t" << eCnt << endl;
cout << "Number of vowel i: \t" << iCnt << endl;
cout << "Number of vowel o: \t" << oCnt << endl;
cout << "Number of vowel u: \t" << uCnt << endl;
cout << "Number of blank: \t" << blkCnt << endl;
cout << "Number of tab: \t" << tabCnt << endl;
cout << "Number of new line: \t" << nlCnt << endl;
return 0;
}