hdu_problem_2027_統計母音

6899 ワード

/*
*
*Problem Description
*                  。
*
*
*Input
*            n,         ,   n      100    。
*
*
*Output
*          5 ,    :
*a:num1
*e:num2
*i:num3
*o:num4
*u:num5
*               。
*
*     :            :)
*
*
*Sample Input
*2
*aeiou
*my name is ignatius
*
*
*Sample Output
*a:1
*e:1
*i:1
*o:1
*u:1
*
*a:2
*e:1
*i:3
*o:0
*u:1
*
*
*Author
*lcy
*
*
*Source
*C        ( )
*
*
*Recommend
*lcy
*
*/
#include
#include
using namespace std;
int a, e, i, o, u;
void num_of_vowel(string s) {
 a = e = i = o = u = 0;
 for (int j = 0; j < s.size(); j++) {
  switch (s.at(j)) {
  case 'a':a++; break;
  case 'e':e++; break;
  case 'i':i++; break;
  case 'o':o++; break;
  case 'u':u++; break;
  default:break;
  }
 }
 printf("a:%d
e:%d
i:%d
o:%d
u:%d
"
, a, e, i, o, u); } int main() { int n; string s; cin >> n; getchar(); for (int i = 0; i < n; i++) { getline(cin, s); num_of_vowel(s); if (i < n - 1)cout << endl; } system("pause"); return 0; }