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 ...
随机推荐
- BZOJ 2243 SDOI 2011染色
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2243 算法讨论: 树链剖分把树放到线段树上.然后线段树的每个节点要维护的东西有左端点的颜色 ...
- 多线程中遇到ASSERT(pMap->LookupPermanent(hWndOrig) == NULL);怎么解决
XP下用VC开发的程序,在一个主线程调用3 个线程,线程之间要共享数据,结果总出现wincore.cpp line 980 ASSERT(pMap-> LookupPermane ...
- php环境安装及搭建
最近由于项目需要 转战 PHP . 在做了差不多两年java后 说实话看php代码还是有些难受的. 毕竟不习惯.废话不说 先说一下 PHP环境的部署等等,也就是最近几天学习的心得吧.方便以后参考. ...
- PHP原始的数据库操作
<?php //这是一个工具类;作用是完成对数据库的操作; class SqlHelper{ public $conn; public $dbname=& ...
- shopnc怎么开启伪静态 shopnc开启伪静态的方法
最近要给一个shopnc网站开启伪静态,用的是shopnc b2b2c,在网上搜索了好多shopnc开启伪静态的方法,但都是针对shaopnc c2c的,没有关于shopnc b2b2c的,最后终于找 ...
- linux tar使用
Linux tar指令简单使用 -c:创建包,-x:解压或解包(-c和-x可理解为互逆运算),-t:查看包 -f:后加处理文件,必须放在参数组合的最后一位(tar -cf a.tar 1.tx ...
- CART剪枝
与上篇文章中提到的ID3算法和C4.5算法类似,CART算法也是一种决策树分类算法.CART分类回归树算法的本质也是对数据进行分类的,最终数据的表现形式也是以树形的模式展现的,CART与ID3,C4. ...
- Codeforces 414B Mashmokh and ACM
http://codeforces.com/problemset/problem/414/B 题目大意: 题意:一个序列B1,B2...Bl如果是好的,必须满足Bi | Bi + 1(a | b 代表 ...
- HDU 4276 The Ghost Blows Light(树形)
题意:给出一棵n个节点的树,起点1,终点n,相连的两个节点之间有距离,每个节点有个价值,给出一个时间T.问从1到达n在给定时间T内取得的最大价值? 思路:先从1走到n,如果总的时间不够走完,直接退出, ...
- PowerShell因为在此系统中禁止执行脚本解决方法
PowerShell因为在此系统中禁止执行脚本解决方法 在Powershell直接脚本时会出现: 无法加载文件 ******.ps1,因为在此系统中禁止执行脚本.有关详细信息,请参阅 " ...