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

import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        char yuan[]={'a','e','i','o','u'};
        int t = sc.nextInt();
        sc.nextLine();
        while(t-->0){
            int yuans[] = new int[yuan.length];
            String strs = sc.nextLine();
            for(int i=0;i<strs.length();i++){
                for(int j=0;j<yuan.length;j++){
                    if(yuan[j]==strs.charAt(i)){
                        yuans[j]++;
                    }
                }
            }
            for(int i=0;i<yuans.length;i++){
                System.out.println(yuan[i]+":"+yuans[i]);
            }
            if(t!=0){
                System.out.println();
            }
        }
    }
}
posted on 2015-12-21 18:25  cnxo  阅读(114)  评论(0编辑  收藏  举报