ACM2027

 

统计元音

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

 

#include<iostream>
int main()
{
    using namespace std;
    char st[101]="\0";
    unsigned short count;
    cin>>count;    cin.get();
    while(count--)
    {
        
        unsigned short yuy[5]={0};
    
        gets(st);
    
        for(int i=0;st[i];++i)
            switch(st[i])
            {
                case 'a':++yuy[0];break;
                case 'e':++yuy[1];break;
                case 'i':++yuy[2];break;
                case 'o':++yuy[3];break;
                case 'u':++yuy[4];break;
            }
            cout<<"a:"<<yuy[0]<<endl
                <<"e:"<<yuy[1]<<endl
                <<"i:"<<yuy[2]<<endl
                <<"o:"<<yuy[3]<<endl
                <<"u:"<<yuy[4]<<endl;
                if(count)
                cout<<endl;
    }    

    return 0;
}

 


posted @ 2013-07-10 17:07  退之  阅读(252)  评论(0编辑  收藏  举报