这一题就是把一个字符串中所有的元音字母找出来,
并且分别把这些元音字母及个数分行输出,
非常简单,主要就是注意一下输出的格式就行了,
下面是代码:
#include <stdio.h>
#include <string>
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
int n, i, j;
char s[5] = {'a','e','i','o','u'};
char str[100], c = ':';
cin >> n;
for (i = 0; i < n; i ++)
{
cin >> str;
int b[5] = {0,0,0,0,0};
for (j = 0; j < strlen(str); j ++)
{
if (str[j] == 'a') b[0] ++;
if (str[j] == 'e') b[1] ++;
if (str[j] == 'i') b[2] ++;
if (str[j] == 'o') b[3] ++;
if (str[j] == 'u') b[4] ++;
}
for (int x = 0; x < 5; x ++)
{
printf ("%c%c%d\n", s[x], c, b[x]);
}
if (i != n-1)
printf ("\n");
}
system ("pause");
return 0;
}