hdu 2027统计元音
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2027
思路:主要考察gets()函数用法,能够接受输入的空格,如果用%s或是cin>>str都不能输入空格
#include <cstdio>
#include <iostream>
#include<algorithm>
#include<math.h>
#include <string.h>
#include<queue>
using namespace std; int main()
{
int a,e,i,o,u;
int num;
char str1[];
while(scanf("%d",&num)!=EOF)
{
getchar(); //吸收回车
for(int j=;j<num;j++)
{
memset(str1,'\0',sizeof(str1));
a=e=i=o=u=;
gets(str1); //gets可以读入空格 for(int j=;j<strlen(str1);j++)
{
if(str1[j] == 'a')
a++;
else if(str1[j] == 'e')
e++;
else if(str1[j] == 'i')
i++;
else if(str1[j] == 'o')
o++;
else if(str1[j] == 'u')
u++;
}
if(j == num-)
{
printf("a:%d\n",a);
printf("e:%d\n",e);
printf("i:%d\n",i);
printf("o:%d\n",o);
printf("u:%d\n",u);
}
else
{
printf("a:%d\n",a);
printf("e:%d\n",e);
printf("i:%d\n",i);
printf("o:%d\n",o);
printf("u:%d\n\n",u);
}
}
}
return ;
}
hdu 2027统计元音的更多相关文章
- hdu 2027 统计元音
统计元音 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- HDOJ 2027 统计元音
Problem Description 统计每个元音字母在字符串中出现的次数. Input 输入数据首先包括一个整数n,表示测试实例的个数,然后是n行长度不超过100的字符串. Output 对于每个 ...
- ACM: HDU 2563 统计问题-DFS+打表
HDU 2563 统计问题 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u HDU 2 ...
- ytu 1939:统计元音(水题)
统计元音 Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 68 Solved: 33[Submit][Status][Web Board] Descrip ...
- HDOJ2027统计元音
统计元音 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- LeetCode 5216. 统计元音字母序列的数目(Java)DP
5216. 统计元音字母序列的数目 给你一个整数 n,请你帮忙统计一下我们可以按下述规则形成多少个长度为 n 的字符串: 字符串中的每个字符都应当是小写元音字母('a', 'e', 'i', 'o', ...
- HDU 2027 汉字统计
汉字统计 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- hdu 1251 统计难题 (字典树入门题)
/******************************************************* 题目: 统计难题 (hdu 1251) 链接: http://acm.hdu.edu. ...
- HDU 1251 统计难题(Trie模版题)
统计难题 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others) Total Subm ...
随机推荐
- go outside @ CULTS LYRICS
I really want to go out I really want to go outside and stop to see your day You really want to hole ...
- linux 下开放端口问题
Linux安装Tomcat后本地可以正常访问,可是这时Tomcat还不能被外界访问需要在Linux默认防护墙上打开8080端口 打开 /etc/sysconfig/iptables [root@l ...
- iOS开发——常见错误——使用MJRefresh返回上一个界面蹦掉的情况
最近在使用MJRefresh框架时发现了一个bug 下面是我的源代码 前一个界面 -(void)tableView:(UITableView *)tableView didSelectRowAtInd ...
- 跟着百度学PHP[4]OOP面对对象编程-9-封装性,访问控制[private、pubic、protected]
其实之前就已经在封装的时候说到了.这个也属于封装的范畴吧. 用到的三个关键字(旁边是其中文翻译) private(私有的) public(公众的) protected(受保护的) 00X1 priva ...
- Servlet的使用方法详细说明
Servlet的生命周期方法: init() destroy() doGet(HttpServletRequest request,HttpServletResponse response) 客户端请 ...
- python 的dict的update 方法的一点诡秘的行为
如下: >>> 'a%s'%a 'a{1: 0, 2: 0}' >>> for k,v in a.items(): a.update(k=v) >>&g ...
- MySQL用法
查询数据库表 通过查询INFORMATION_SCHEMA.TABLES查询数据库表的结构信息 SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TAB ...
- ubuntu查看端口占用
查看端口号 sudo netstat -ltnp | 结束进程 sudo kill pid
- Minimum Adjustment Cost
Given an integer array, adjust each integers so that the difference of every adjacent integers are n ...
- 在asp.net mvc中上传大文件
在asp.net mvc 页面里上传大文件到服务器端,需要如下步骤: 1. 在Control类里添加get 和 post 方法 // get method public ActionResult Up ...