当前位置:网站首页>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;
}
边栏推荐
- Project (7) - PolarSeg point cloud semantic segmentation
- Win11怎么关闭系统保护功能?系统保护还原功能怎么关闭?
- 聚焦热点 | ISC 2022软件供应链安全治理与运营论坛圆满落幕
- 365天挑战LeetCode1000题——Day 052 逐步求和得到正数的最小值 贪心
- 2022中高级Android面试题汇总来助你通过面试
- CAS:183896-00-6 (Biotin-PEG3-C3-NH2) PEG derivative
- labelme标注的json标签转txt格式
- deepstream学习笔记(三):deepstream-imagedata-multistream解析与接入适配yolov5模型测试
- 由生物素参与的D-Biotinol,CAS号:53906-36-8具体特性说明
- Mysql数据库 ALTER 基本操作
猜你喜欢
随机推荐
The older tester has just passed the "hurdle" of being 35 years old, and I want to tell you something from my heart
2022中高级Android面试题汇总来助你通过面试
地雷数量求解
Next.js获取路由参数及styled-jsx 的使用
labelme标注的json标签转txt格式
由生物素参与的D-Biotinol,CAS号:53906-36-8具体特性说明
CAS:183896-00-6 (Biotin-PEG3-C3-NH2) PEG derivative
Redisson 分布式锁
Fury:一个基于JIT动态编译的高性能多语言原生序列化框架
深入理解Aarch64内存管理
PEG 衍生物Biotin-PEG1-OH(cas:95611-10-2,2-生物素氨基乙醇)优势说明
mysql无法远程连接 Can‘t connect to MySQL server on ‘xxx.xxx.xxx.xxx‘ (10060 “Unknown error“)
-Vector Dot Product-
Enhanced Deep Residual Networks for Single Image Super-Resolution
selenium和驱动安装
Impala 疑问
vmware Exsi 网卡配置
hql语言
从TRPO到PPO(理论分析与数学证明)
LeetCode常见题型——链表