I-Problem I
统计每个元音字母在字符串中出现的次数。
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
#include <iostream>
#include<string>
using namespace std;
int main()
{
int n;char str[101];
cin>>n;
while(n--)
{
int j=0,a=0,e=0,i=0,o=0,u=0;
cin>>str;
while(str[j]!='\0')
{
if(str[j]=='a')
a++;
else if(str[j]=='e')
e++;
else if(str[j]=='i')
i++;
else if(str[j]=='o')
o++;
else if(str[j]=='u')
u++;
j++;
}
if(n>0) cout<<"a:"<<a<<endl<<"e:"<<e<<endl<<"i:"<<i<<endl<<"o:"<<o<<endl<<"u:"<<u<<endl<<endl;
else cout<<"a:"<<a<<endl<<"e:"<<e<<endl<<"i:"<<i<<endl<<"o:"<<o<<endl<<"u:"<<u<<endl;
}
}