统计元音

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 46701    Accepted Submission(s): 19038


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
 

 

Recommend
lcy   |   We have carefully selected several similar problems for you:  1062 1256 1020 1075 2072 
 
 1 #include <stdio.h>
 2 #include <string.h>
 3 int main()
 4 {
 5     char str[110] ;
 6     int i, n ;
 7     while(~scanf("%d", &n))
 8     {
 9         getchar() ;  //为什么必须放在这边 ?
10          while(n--)
11         {
12             gets(str) ;
13             int len = strlen (str) ;
14             int a=0, b=0, c=0, d=0, e=0 ;
15             for(i=0; i<len; i++)
16             {
17                 if(str[i] == 'a')
18                 a++ ;
19                 if(str[i] == 'e')
20                 b++ ;
21                 if(str[i] == 'i')
22                 c++ ;
23                 if(str[i] == 'o')
24                 d++ ;
25                 if(str[i] == 'u')
26                 e++ ;
27             }
28             printf("a:%d\n",a) ;
29             printf("e:%d\n",b) ;
30             printf("i:%d\n",c) ;
31             printf("o:%d\n",d) ;
32             printf("u:%d\n",e) ;
33             if(n!=0)
34             printf("\n") ;
35         }
36     }
37     return 0 ;
38 } 

 

posted on 2015-07-21 19:09  cleverbiger  阅读(203)  评论(0编辑  收藏  举报