hdu1219
Problem Description
Ignatius is doing his homework now. The teacher gives him some articles and asks him to tell how many times each letter appears.
It's really easy, isn't it? So come on and AC ME.
Input
Each article consists of just one line, and all the letters are in lowercase. You just have to count the number of each letter, so do not pay attention to other characters. The length of article is at most 100000. Process to the end of file.
Note: the problem has multi-cases, and you may use "while(gets(buf)){...}" to process to the end of file.
Output
For each article, you have to tell how many times each letter appears. The output format is like "X:N".
Output a blank line after each test case. More details in sample output.
Sample Input
hello, this is my first acm contest!
work hard for hdu acm.
Sample Output
a:1
b:0
c:2
d:0
e:2
f:1
g:0
h:2
i:3
j:0
k:0
l:2
m:2
n:1
o:2
p:0
q:0
r:1
s:4
t:4
u:0
v:0
w:0
x:0
y:1
z:0
a:2
b:0
c:1
d:2
e:0
f:1
g:0
h:2
i:0
j:0
k:1
l:0
m:1
n:0
o:2
p:0
q:0
r:3
s:0
t:0
u:1
v:0
w:1
x:0
y:0
z:0
题的大概意思就是计算a-z出现的次数;
代码:
#include <iostream>
#include <string>
#include <cstring>
#include <stdio.h>
using namespace std;
int main()
{ int a[27];char c;
string st;
while(getline(cin,st)){
memset(a,0,sizeof(a));
for(int i=0;i<st.size();i++)
if(st[i]>='a'&&st[i]<='z')
a[st[i]-97]++;
for(int i=0;i<26;i++)
{
c=i+97;
cout<<c<<":"<<a[i]<<endl;
}
cout<<endl;
}
return 0; }
hdu1219的更多相关文章
- 【HDU1219】AC Me(水题)
BUPT2017 wintertraining(16) #4 A HDU1219 题意 多组样例,每组给一行,输出该行各字母个数,每组输出之间输出空行 代码 #include <cstdio&g ...
- OJ题目分类
POJ题目分类 | POJ题目分类 | HDU题目分类 | ZOJ题目分类 | SOJ题目分类 | HOJ题目分类 | FOJ题目分类 | 模拟题: POJ1006 POJ1008 POJ1013 P ...
- 2019的hdu暑假作业(欢迎纠错)
1219 遍历计数. #include<bits/stdc++.h> #define QAQ 0 using namespace std; ]; ]; int main(){ )){ me ...
随机推荐
- (一)原生JS实现 - 基本类方法
类 var Class = { create: function() { return function() { this.initialize.apply(this, arguments); } } ...
- python进行base64编解码
[转] 直接上代码 import base64 fin = open(r"D:\2.zip", "rb") fout = open(r"D:\2.x. ...
- Mysql学习(慕课学习笔记1)启动、登录及常用命令
Mysql学习 启动数据库服务 net start mysql (不能加分号!!!!) 关闭数据库服务 net stop mysql 登录数据库 mysql -uroot -p -P3306 - ...
- 【1】Laravel5.1 安装
1.安装composer http://www.phpcomposer.com/ 这个是中文网址里边有教程,但是由于被墙的缘故,可以通过下边这个链接下载Windows安装包 http://docs.p ...
- HTML5视频
<video>标签用于定义视频. 案例1: <!DOCTYPE html><html><head lang="en"> <me ...
- 【转】myget编译过程中make出错的解决办法
源链接:http://www.tangqizhong.info/?p=741 myget(至今不明白为什么它对应的命令是mytget…)是我从用linux之后就开一直在用的命令行下载工具(其次也会用到 ...
- 根据文字计算Label的尺寸
CGSize size = [self.username.text boundingRectWithSize:(CGSize){130,20} options:NSStringDrawingUsesL ...
- Core Data的使用(二)备
一.基础概念深入 1.NSManagedObjectContext 被管理数据上下文就像便笺簿 当从数据持久层获取数据时,相当于把这些临时的数据拷贝写在便笺簿上,然后就可以随心所欲的修改这些值. 通过 ...
- 让 SpringMVC 接收多个对象的4种方法
问题背景: 我要在一个表单里同时一次性提交多名乘客的个人信息到SpringMVC,前端HTML和SpringMVC Controller里该如何处理? 第1种方法:表单提交,以字段数组接收: 第2种方 ...
- java链接sqlite资料整理
0.SQLite三种JDBC驱动的区别 摘自http://blog.sina.com.cn/s/blog_654337ca01016x4n.html 在DBeaver中看到SQLite有三种JDBC驱 ...