HDOJ 2027 统计元音
来源:互联网 发布:三方博弈矩阵 编辑:程序博客网 时间:2024/06/04 20:11
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2027
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 <stdio.h>#include <ctype.h> int main() { char c; int a[5]; int n; scanf("%d%*c", &n); while (n--) { a[0] = a[1] = a[2] = a[3] = a[4] = 0; while ((c = getchar()) != '\n') { switch (tolower(c)) { case 'a': a[0]++; break; case 'e': a[1]++; break; case 'i': a[2]++; break; case 'o': a[3]++; break; case 'u': a[4]++; break; default: break; } } printf("a:%d\n", a[0]); printf("e:%d\n", a[1]); printf("i:%d\n", a[2]); printf("o:%d\n", a[3]); printf("u:%d\n", a[4]); if (n) putchar('\n'); }}
阅读全文
0 0
- hdoj 2027 统计元音
- hdoj 2027 统计元音
- HDOJ 2027 统计元音
- HDOJ 2027 统计元音
- HDOJ 2027 统计元音
- HDOJ 2027 统计元音
- HDOJ 2027 统计元音
- hdoj.2027 统计元音 20140726
- hdoj 2027 统计元音 C++
- hdoj 2027 统计元音 (字符串)
- c++ hdoj 2027 统计元音
- [水题][第一阶段-回归水题][HDOJ-2027]统计元音
- HDOJ 2027 统计元音
- hdu 2027 统计元音
- 2027 统计元音
- HDU 2027 统计元音
- HDU 2027 统计元音
- Hdu 2027 - 统计元音
- jsp
- Machine Learning第十讲[大规模机器学习]
- linux高级网络配置基础team和网桥
- Python-基础学习笔记(六)
- Linux虚拟网络之tun(四)虚拟VPN
- HDOJ 2027 统计元音
- crontab
- 错误:Property of 'java.util.Set<?>' type cannot be injected by 'List'的解决方案
- Multiply Strings(大数相乘)
- Q107:Linux系统下GDB对PBRT-V3进行debug
- unity 鼠标悬停事件
- js创建型设计模式--简单工厂模式
- SmsManager发短信_随笔
- altium designer 13学习之添加泪滴