Hust oj 1629 统计图(水题)
来源:互联网 发布:液晶电视怎样连接网络 编辑:程序博客网 时间:2024/05/21 06:12
统计图Time Limit: 1000 MSMemory Limit: 32768 KTotal Submit: 139(56 users)Total Accepted: 61(51 users)Rating: Special Judge: NoDescription
用一个直方图统计每个大写字母出现的次数。
Input本题只有一组测试数据,输入n行,n未知,每行输入一个字符串,每个字符串的长度不会超过100。
Output输出直方图。
Sample InputHAPPY NEW YEAR!
WA? PE? RE? TLE? MLE? AC!
BBFFIIQQUUVVZZ ^.^
AN AC A DAY KEEPS THE DOCTOR AWAY~
*
* *
* *
* *
* *
* *
* * * *
* * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * *
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<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;const int Maxn = 105;int Inf = 0x3f3f3f;char str[Maxn];int cont[26];int main(){ int t = 4; int Max = -Inf; memset(cont,0,sizeof(cont)); while(gets(str) != NULL) { int len = strlen(str); for(int i=0;i<len;i++) { if(str[i] >= 'A' && str[i] <= 'Z') { cont[str[i]-'A']++; if(cont[str[i]-'A'] > Max) { Max = cont[str[i]-'A']; } } } } for(int i=Max;i>=1;i--) { for(int j=0;j<26;j++) { if(cont[j] == i) { printf("*"); cont[j]--; } else printf(" "); if(j != 25) printf(" "); } printf("\n"); } for(int i=0;i<26;i++) { printf("%c",i+'A'); if(i != 25) printf(" "); }}
0 0
- Hust oj 1629 统计图(水题)
- Hust oj 1369 Buy Computers(水题)
- Hust oj 2121 你猜猜(水题)
- Hust oj 2235 毒(水题)
- Hust oj 2125 钱多多(水题)
- Hust oj 1693 Difficult work(水题)
- Hust oj 2000 极差(水题)
- Hust oj 1720 Fibonacci Numbers(水题)
- Hust oj 1431 摞盘子(水题)
- Hust oj 1046 Balls Collision(水题)
- Hust oj 2084(大数)
- Hust oj 1394 XianGe的游戏I(水题)
- Hust oj 1197 Cuts the cake(水题)
- Hust oj 1384 Leyni, LOLI and Toasts(水题)
- Hust oj 2116 Maximum continuous product(水题)
- Hust oj 1673 2013新的旅程(水题)
- Hust oj 1754 Minimum Scalar Product(水题)
- Hust oj 1648 Tailmon与序列(水题)
- Android学习之自己需要提高和巩固的知识
- OC NSString的定义方法
- java获取路径
- uva 1218 完美服务器 树形dp 染色问题
- Ubuntu16.04下安装ns2.35
- Hust oj 1629 统计图(水题)
- OSGI 框架搭建
- Hibernate使用注解配置映射
- 剑指offer[8]变态跳台阶
- hdu 4664 Triangulation
- Android中Bitmap的分析与使用
- HDU5444(2015长春网赛)——Elven Postman(树的遍历,dfs)
- android stadio svn 使用技巧
- unix和dos文本文件的区别