-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrefactor3.cpp
74 lines (65 loc) · 1.34 KB
/
refactor3.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
#include <iostream>
#include <string>
int getIndex(char c) {
switch(c) {
case 'a' : {
return 0;
break;
}
case 'A' : {
return 0;
break;
}
case 'e': {
return 1;
break;
}
case 'E': {
return 1;
break;
}
case 'i' : {
return 2;
break;
}
case 'I' : {
return 2;
break;
}
case 'o' : {
return 3;
break;
}
case 'O' : {
return 3;
break;
}
case 'u' : {
return 4;
break;
}
case 'U': {
return 4;
break;
}
default :{
return 5;
break;
}
}
}
int main() {
std::string str = "Only for testing purpose.";
int count[5] = {0}, x;
int len=str.length();
for(int i = 0; i<len; i++) {
x = getIndex(str[i]);
if(x<5) count[x]+=1;
}
std::cout << "\n count[0]: " << count[0];
std::cout << "\n count[1]: " << count[1];
std::cout << "\n count[2]: " << count[2];
std::cout << "\n count[3]: " << count[3];
std::cout << "\n count[4]: " << count[4];
std::cout << "\n\n";
}