Statistical vowels
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 37878 accepted submission (s): 15559
The Problem description counts the number of times each vowel appears in a string.
Input data first contains an integer N, indicating the number of test instances, followed by a string of N rows with a length not greater than 100.
Output outputs 5 rows for each test instance in the following format:
A: num1
E: num2
I: num3
O: num4
U: num5
Multiple test instances are separated by one blank line.
Note: There are no blank lines after the last output :)
Sample Input
2aeioumy name is ignatius
Sample output
a:1e:1i:1o:1u:1a:2e:1i:3o:0u:1
Authorlcy
Sourcec language programming exercises (4)
Recommendlcy | we have carefully selected several similar problems for you: 2031 2032 2030 2028
Still have questions. Well, pay attention to PE problems.
#include <iostream>using namespace std;int main(){int n;char a[105];cin >> n;getchar();while (n--){gets(a);int b[5] = { 0 };for (int i = 0; i < strlen(a); i++){if (a[i] == 'a')b[0]++;else if (a[i] == 'e')b[1]++;else if (a[i] == 'i')b[2]++;else if (a[i] == 'o')b[3]++;else if (a[i] == 'u')b[4]++;}cout << "a:" << b[0] << endl;cout << "e:" << b[1] << endl;cout << "i:" << b[2] << endl;cout << "o:" << b[3] << endl;cout << "u:" << b[4] << endl;if (n!=0)cout << endl;}cin >> a;return 0;}
Hdoj 2027 statistical vowels