当前位置:网站首页>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;
}
边栏推荐
- MATLB|和她跌宕起伏最终到达人生之峰【浪漫旅途】
- Fury:一个基于JIT动态编译的高性能多语言原生序列化框架
- EL表达式
- Mysql database ALTER basic operations
- Docker 面试题2则--取数据库连接数和docker-compose
- MATLB|And her ups and downs and finally reached the peak of life [Romantic Journey]
- JVM Memory and Garbage Collection - 10. Direct Memory
- JVM内存和垃圾回收-10.直接内存
- 【C语言】通讯录《静态内存版本》
- 今日睡眠质量记录61分
猜你喜欢
今日睡眠质量记录61分
Leetcode82. 删除排序链表中的重复元素 II
CAS:183896-00-6 (Biotin-PEG3-C3-NH2) PEG derivative
3.1 - 程序设计语言 3.2 - 高级语言的特点及引用 3.3 - 静态/动态类型语言
温度响应性纳米水凝胶光子品体/纤维素修饰荧光水凝胶/载脂质体水凝胶的制备方法
WPF DataGrid 使用数据模板
Win11怎么关闭系统保护功能?系统保护还原功能怎么关闭?
deepstream学习笔记(三):deepstream-imagedata-multistream解析与接入适配yolov5模型测试
365天挑战LeetCode1000题——Day 052 逐步求和得到正数的最小值 贪心
02|运算符
随机推荐
Kubernetes YAML编写 讲解
[obs] obsqsv11 hard coding and comparison with metartc codec
Mysql数据库 ALTER 基本操作
第十二,十三章 mysql数据类型,视图的课后练习
LSTM-based distributed energy generation prediction (Matlab code implementation)
拒绝“重复造轮子”,百度EasyDL让你玩转AI定制开发
基于FPGA的任意字节数的串口接收(含源码工程)
最高月薪15K,谁有历经千辛万苦的意志,谁就能收获属于自己的成功~
为什么不建议你在 Docker 中跑 Mysql ?
线程的同步与互斥
Leetcode80. 删除有序数组中的重复项 II
【毕业设计】基于ESP32的在线墨水屏桌面摆件 -物联网 单片机 嵌入式
网络协议05 -网络层
服装店管理系统如何推送活动?
足不出户也能看星空
Biotin-Cy2 Conjugate,生物素-Cy2 偶联物_Cy2 生物素偶联物
微信公众号如何开通支付功能?
【Django】缓存
c语言结构体、函数以及指针练习(简单通讯录)
365天挑战LeetCode1000题——Day 052 逐步求和得到正数的最小值 贪心