当前位置:网站首页>Character Statistics Histogram
Character Statistics Histogram
2022-08-10 01:47:00 【-JMY-】
Title description
Xiao Ming has been playing a character game recently. The rules are as follows: Read in a four-line string, where the letters are all uppercase, and Xiaoming wants to print a histogram showing the frequency of each uppercase letter.Can you help him?
Enter
A total of 4 lines: each line is a string of characters, no more than 100 characters.
Output
Strictly follow the format of the sample.
Sample input
THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG.THIS IS AN EXAMPLE TO TEST FOR YOURHISTOGRAM PROGRAM.HELLO!
Sample output
***** * * ** * * ** * * * * ** * * * * * * * * ** * * * * * * * * * * * ** * * * * * * * * * * * * * * * * ** * * * * * * * * * * * * * * * * * * * * * * * *A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Reference code:
#include
using namespace std;
string s;
int maxn,t[26];
int main(){
for(int i=0;i<4;i++){
getline(cin,s);
for(int j=0;j
t[s[j]-'A']++;
maxn=max(maxn,t[s[j]-'A']);
}
for(int i=maxn;i>0;i--){
for(int j=0;j<26;j++){
if(t[j]>=i)
printf("* ");
else if(t[j]!=0)
, printf("");
}
printf("\n");
}
for(int i=0;i<26;i++)
if(t[i]!=0)
printf("%c ",'A'+i);
return 0;
}
边栏推荐
猜你喜欢
由生物素参与的D-Biotinol,CAS号:53906-36-8具体特性说明
基于 LSTM 的分布式能源发电预测(Matlab代码实现)
温度响应性纳米水凝胶光子品体/纤维素修饰荧光水凝胶/载脂质体水凝胶的制备方法
【数据存储】signed,unsigned到底怎么区分?如何计算?
[C language] In-depth understanding of pointers and arrays (issue 4)
【CAS:41994-02-9 |Biotinyl tyramide】生物素基酪氨酰胺价格
Next.js获取路由参数及styled-jsx 的使用
2022金九银十工作潮,怎么样才能成功跳槽面试拿到高薪呢?
Win7怎么把控制面板添加到右键菜单
The technical aspects of the byte have been passed, and the salary has been negotiated for 20K*13, but the result is still being brushed. I asked the HR why...
随机推荐
selenium和驱动安装
最高月薪15K,谁有历经千辛万苦的意志,谁就能收获属于自己的成功~
nfs配置
What should I do if there is no sound after reinstalling the system in win10?
【猜凶手,猜名次,杨辉三角】经典小学奥数的代码逻辑是什么?
Leetcode82. 删除排序链表中的重复元素 II
Today's sleep quality record 61 points
基于 LSTM 的分布式能源发电预测(Matlab代码实现)
Creo5.0 introductory tutorial free material
[obs] obsqsv11 hard coding and comparison with metartc codec
Web性能测试模型小结
The older tester has just passed the "hurdle" of being 35 years old, and I want to tell you something from my heart
【C语言】通讯录《静态内存版本》
安全知识培训——消防安全
-红与黑-
openEuler 知:abi 检测
Kubernetes 开发环境比对
LeetCode常见题型——链表
大龄测试员刚迈过了 35 岁这个“坎儿”,和大家说点儿心里话
MATLB|和她跌宕起伏最终到达人生之峰【浪漫旅途】