当前位置:网站首页>字符统计柱状图
字符统计柱状图
2022-08-09 23:46:00 【-JMY-】
题目描述
小明最近玩起了字符游戏,规则是这样的:读入四行字符串,其中的字母都是大写的,小明想打印一个柱状图显示每个大写字母的频率。你能帮助他吗?
输入
共有4行:每行为一串字符,不超过100个字符。
输出
与样例的格式保持严格一致。
样例输入
THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG. THIS IS AN EXAMPLE TO TEST FOR YOUR HISTOGRAM PROGRAM. HELLO!
样例输出
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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
参考代码:
#include<bits/stdc++.h>
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<s.size();j++)
if(s[j]>='A'&&s[j]<='Z'){
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;
}
边栏推荐
- Pinduoduo store operation must know to leave a little knowledge of operation
- 【毕业设计】基于ESP32的在线墨水屏桌面摆件 -物联网 单片机 嵌入式
- Today's sleep quality record 61 points
- 微信公众号如何开通支付功能?
- 如何抑制告警风暴?
- 基于 LSTM 的分布式能源发电预测(Matlab代码实现)
- 考柏的感慨
- 【问题解决】训练和验证准确率很高,但测试准确率很低
- Redis 非关系型数据库学习(一) ---- Redis 的安装
- C language learning journey [operator (incomplete version)]
猜你喜欢
Creo5.0 introductory tutorial free material
【问题解决】训练和验证准确率很高,但测试准确率很低
【毕业设计】基于ESP32的在线墨水屏桌面摆件 -物联网 单片机 嵌入式
微服务【同步和异步通讯详解】第6章
收银管理软件如何做好员工管理?
JVM Memory and Garbage Collection - 10. Direct Memory
Service Discovery @EnableDiscoveryClient
【Infiltration tool】Browser data export tool
数字孪生智慧制造生产线项目实施方案,平台认知与概念
Creo5.0入门教程赠素材
随机推荐
大龄测试员刚迈过了 35 岁这个“坎儿”,和大家说点儿心里话
GoLang 使用 goroutine 停止的几种办法
Web性能测试模型小结
【问题解决】训练和验证准确率很高,但测试准确率很低
微服务【同步和异步通讯详解】第6章
Kubernetes服务接入Istio
【Infiltration tool】Browser data export tool
Alibaba Cloud SMS Service Activation
arm-4-裸板开发
3.1 - 程序设计语言 3.2 - 高级语言的特点及引用 3.3 - 静态/动态类型语言
JVM Memory and Garbage Collection - 10. Direct Memory
Tensor flow 踩坑记
【C语言】通讯录《静态内存版本》
CAS:851113-28-5 (生物素-ahx-ahx-酪胺)
Pinduoduo store operation must know to leave a little knowledge of operation
Kubernetes 开发环境比对
Impala 疑问
go语言的并发原理(goroutine)
【毕业设计】 基于Stm32的家庭智能监控系统 - 单片机 图像识别 人体检测 AI
nfs配置