当前位置:网站首页>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|And her ups and downs and finally reached the peak of life [Romantic Journey]](/img/10/55cc34a929768d89d9ffde8a5b3419.png)
MATLB|And her ups and downs and finally reached the peak of life [Romantic Journey]

3.11-程序基本的控制语句 3.12-表达式 3.13-数据类型 3.14-常量/变量 3.15-标识符

Leetcode79. 单词搜索

CAS:851113-28-5 (Biotin-ahx-ahx-tyramine)

有PEG-Biotin参与的(CAS:1778736-18-7)Biotin-PEG4-OH广泛用于分子靶点检测

算法---整数替换(Kotlin)

Today's sleep quality record 61 points

基于FPGA的任意字节数的串口接收(含源码工程)

网络协议05 -网络层

dlopen failed: library "libtaml.so" not found
随机推荐
基于ABP的AppUser对象扩展
第十五章 mysql存储过程与存储函数课后练习
CAS:851113-28-5 (生物素-ahx-ahx-酪胺)
CST Studio Suite 2021 software installation package and installation tutorial
微服务【同步和异步通讯详解】第6章
PEG 衍生物Biotin-PEG1-OH(cas:95611-10-2,2-生物素氨基乙醇)优势说明
安全知识培训——消防安全
MATLB|和她跌宕起伏最终到达人生之峰【浪漫旅途】
地雷数量求解
大龄测试员刚迈过了 35 岁这个“坎儿”,和大家说点儿心里话
labelme标注的json标签转txt格式
字符统计柱状图
Next.js获取路由参数及styled-jsx 的使用
02|运算符
Redisson 分布式锁
EL表达式
dlopen failed: library "libtaml.so" not found
从TRPO到PPO(理论分析与数学证明)
【Django】缓存
Docker 面试题2则--取数据库连接数和docker-compose