统计元音 hd 2027
2016-07-21 23:37
357 查看
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
统计每个元音字母在字符串中出现的次数。
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<stdio.h> #include<string.h> int main() { int n,c,d,e,f,g,i,b; char a[110]; scanf("%d",&n); getchar(); while(n--) { c=0; d=0; e=0; f=0; g=0; gets(a); b=strlen(a); for(i=0;i<b;i++) { if(a[i]=='a') c++; if(a[i]=='e') d++; if(a[i]=='i') e++; if(a[i]=='o') f++; if(a[i]=='u') g++; } printf("a:%d\n",c); printf("e:%d\n",d); printf("i:%d\n",e); printf("o:%d\n",f); printf("u:%d\n",g); if(n) printf("\n");<span style="white-space:pre"> </span>//后面是两个空行 } }
相关文章推荐
- fwrite与xxd这对黄金搭档帮我定位出乱码问题------无法打印日志时如何打日志?
- 2016-7-21 无其他浏览器,周末用其他浏览器在MArkDown下写,并贴代码
- Java之this关键字的用法
- ScrollView嵌套ListView问题
- Codeforces Good Bye 2015 A. New Year and Days
- 响应者链条
- Linux命令常用之find
- 视图的生命周期
- 管理信息系统的技术观和经营观
- 将博客搬至CSDN
- linux64位使用phantomjs获取页面截图
- Poj3468 A Simple Problem with Integers 线段树、区间更新
- HDU 4274-Spy's Work-树dp
- openGL的初步入门
- Codeforces 610A Pasha and Stick
- Leetcode Clone Graph
- 【最短路径】:Dijkstra算法、SPFA算法、Bellman-Ford算法和Floyd-Warshall算法
- JSP定义和四大范围
- HttpSession对象
- 蓝桥杯 ADV-83算法提高 寻找三位数