P1598 垂直柱状图
发布时间:2020-12-16 10:48:58 所属栏目:百科 来源:网络整理
导读:P1598 垂直柱状图 题目链接:https://www.luogu.org/problem/P1598 代码: #include bits/stdc++.husing namespace std;int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int t[100]={0},b1,c1,d1,a1,i; char a[1000],b[1000],
P1598 垂直柱状图题目链接:https://www.luogu.org/problem/P1598 代码: #include <bits/stdc++.h> using namespace std; int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int t[100]={0},b1,c1,d1,a1,i; char a[1000],b[1000],c[1000],d[1000]; gets(a); gets(b); gets(c); gets(d); a1 = strlen(a); b1 = strlen(b); c1 = strlen(c); d1 = strlen(d); for(i=0;i<a1;i++){ if(a[i]>=65&&a[i]<=90){ t['Z'-a[i]]++; } } for(i=0;i<b1;i++){ if(b[i]>=65&&b[i]<=90){ t['Z'-b[i]]++; } } for(i=0;i<c1;i++){ if(c[i]>=65&&c[i]<=90){ t['Z'-c[i]]++; } } for(i=0;i<d1;i++){ if(d[i]>=65&&d[i]<=90){ t['Z'-d[i]]++; } } int l[30],max=0,j; for(i=0;i<26;i++){ l[i] = t[25-i]; //注意,因为两数相减所以将数存进t的数组时相反; if(l[i]>max){ max = l[i]; //找到柱状图的高; } } int p =max; for(i=0;i<max;i++){ for(j=0;j<26;j++){ if(l[j]>=p){ cout<<"* "; }else{ cout<<" "; } } cout<<endl; p--; } for(i=0;i<26;i++){ printf("%c ",'A'+i); } return 0; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- flexbox布局text文本单行显示多余省略号代替
- 在 TextView 中设定义在xml档中有帯参数的字符串
- cocos2dx,elipse,Errors occurred during the build,java.l
- 谈谈jQuery Ajax用法详解
- C# – 系统地添加界面一个很好的做法?
- ruby – 由minitest单元测试创??建的回滚更改
- 一步步教你利用webpack如何搭一个vue脚手架(超详细讲解和注
- postgresql – 使用pgadmin3连接到远程主机上的docker容器中
- 关于CCV1.3源码的调试
- SQLite 授权动作编码(AuthorizerAction Codes)