Vertical Histogram

Time Limit: 1000MS Memory Limit: 65536K

Total Submissions: 21223 Accepted: 10048

Description

Write a program to read four lines of upper case (i.e., all CAPITAL LETTERS) text input (no more than 72 characters per line) from the input file and print a vertical histogram that shows how many times each letter (but not blanks, digits, or punctuation) appears in the all-upper-case input. Format your output exactly as shown.

Input

  • Lines 1…4: Four lines of upper case text, no more than 72 characters per line.

    Output

  • Lines 1…??: Several lines with asterisks and spaces followed by one line with the upper-case alphabet separated by spaces. Do not print unneeded blanks at the end of any line. Do not print any leading blank lines.

    Sample Input

THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG.

THIS IS AN EXAMPLE TO TEST FOR YOUR

HISTOGRAM PROGRAM.

HELLO!

Sample Output

  1. *
  2. *
  3. * *
  4. * * * *
  5. * * * *
  6. * * * * * *
  7. * * * * * * * * * *
  8. * * * * * * * * * * * * *
  9. * * * * * * * * * * * * * * * * * *
  10. * * * * * * * * * * * * * * * * * * * * * * * * * *
  11. 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

Source

USACO 2003 February Orange

题意很简单,统计每个字母的个数,但是打印起来比较麻烦,签到题。

  1. #include<iostream>
  2. #include<map>
  3. #include<cstring>
  4. #include<cstdio>
  5. #include<string>
  6. using namespace std;
  7. char a[100];
  8. char b[100];
  9. char c[100];
  10. char d[100];
  11. int ob[25];
  12. int main()
  13. {
  14. int ans=0;
  15. memset(ob,0,sizeof(ob));
  16. gets(a);
  17. gets(b);
  18. gets(c);
  19. gets(d);
  20. for(int i=0;i<100;i++){
  21. if(a[i]>='A'&&a[i]<='Z') ob[a[i]-'A'+1]++;
  22. if(b[i]>='A'&&b[i]<='Z') ob[b[i]-'A'+1]++;
  23. if(c[i]>='A'&&c[i]<='Z') ob[c[i]-'A'+1]++;
  24. if(d[i]>='A'&&d[i]<='Z') ob[d[i]-'A'+1]++;
  25. }
  26. for(int i=0;i<=26;i++)
  27. ans=max(ob[i],ans);
  28. for(int i=ans;i>=1;i--){
  29. for(int j=1;j<=26;j++)
  30. if(ob[j]>=i)cout<<"* ";
  31. else cout<<" ";
  32. cout<<endl;
  33. }
  34. for(int j=0;j<=25;j++)
  35. {
  36. cout<<char(j+'A')<<' ';
  37. }
  38. }

POJ 2136 Vertical Histogram(当时写的比较恶心,优化一下)的更多相关文章

  1. Poj 2136 Vertical Histogram(打印垂直直方图)

    一.Description Write a program to read four lines of upper case (i.e., all CAPITAL LETTERS) text inpu ...

  2. poj 2136 Vertical Histogram 解题报告

    题目链接:http://poj.org/problem?id=2136 题意不难理解,就是输入四行字符串(每行字符总数不超过72个),统计26个英文字母的数目,并按柱状图的形式输出.我的思路就是,先用 ...

  3. POJ 2136 Vertical Histogram

    题意:按样例那样模拟…… 解法:模拟…… 代码: #include<stdio.h> #include<iostream> #include<algorithm> ...

  4. J - Vertical Histogram(1.5.7)

    J - Vertical Histogram(1.5.7) Time Limit:1000MS    Memory Limit:65536KB    64bit IO Format:%I64d &am ...

  5. POJ 3635 - Full Tank? - [最短路变形][手写二叉堆优化Dijkstra][配对堆优化Dijkstra]

    题目链接:http://poj.org/problem?id=3635 题意题解等均参考:POJ 3635 - Full Tank? - [最短路变形][优先队列优化Dijkstra]. 一些口胡: ...

  6. POJ 3013 Big Christmas Tree(最短Dijkstra+优先级队列优化,SPFA)

    POJ 3013 Big Christmas Tree(最短路Dijkstra+优先队列优化,SPFA) ACM 题目地址:POJ 3013 题意:  圣诞树是由n个节点和e个边构成的,点编号1-n. ...

  7. 打表格,字符串处理,POJ(2136)

    题目链接:http://poj.org/problem?id=2136 水题WA了半天,结果是数组开小了. #include <stdio.h> #include <string.h ...

  8. POJ 2136

    #include <iostream> #include <string> #define MAXN 26 using namespace std; int _m[MAXN]; ...

  9. 【POJ2136】Vertical Histogram(简单模拟)

    比较简单,按照样例模拟就好!~ #include <iostream> #include <cstdlib> #include <cstdio> #include ...

随机推荐

  1. gdb调试工具常用命令 && kdb

    编译程序时需要加上-g,之后才能用gdb进行调试:gcc -g main.c -o main gdb中命令: 回车键:重复上一命令 (gdb)help:查看命令帮助,具体命令查询在gdb中输入help ...

  2. HAproxy shell脚本安装

    #!/bin/bash #需要lua-..tar.gz在家目录下 # 编译安装lua #安装编译环境需要的包 yum -y install gcc openssl-devel pcre-devel s ...

  3. shell脚本编程(ubantu)

    项目 内容 这个作业属于那个课程 这里是链接 作业要求在哪里 这里是链接 学号-姓名 17041506-张政 作业学习目标 了解shell脚本的概念及使用:掌握shell脚本语言的基本语法:学习简单的 ...

  4. alg-链表中有环

    typedef struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(nullptr) {} }ListN ...

  5. awk线程号

    for i in `ps|grep [a]out|awk '{print $1}'` do kill -9 "$i" done

  6. 在java 中一种简单方式的声明静态Map常量的方法

    我现在需要在一个类里面放一个HashMap,往里面放一些数据,每次要从数据库中取数据的时候先查找HashMap,看是否已经存在,若存在就直接提取,若不存在就从数据库中抽取数据之后再放到HashMap中 ...

  7. Daily Scrum 12/21/2015

    Process: Zhaoyang: Integrate the oxford Speech API Code to the IOS client and do some UI optimizatio ...

  8. timer和ScheduledThreadPoolExecutor定时任务和每日固定时间执行

    //ScheduledThreadPoolExecutor每三秒执行一次 public static void main(String[] args) {        ScheduledThread ...

  9. 多窗体及窗体之间传值 以及listview的使用

    三中打开窗口窗体状态: 1   messagebox.show 类型  特点: 从窗口form 1里打开另一个窗体form2,form2不关闭的情况下form1 不能操作:代码如下: private ...

  10. Jmeter系列(1)- 环境部署

    如果你想从头学习Jmeter,可以看看这个系列的文章哦 https://www.cnblogs.com/poloyy/category/1746599.html 官网下载Jmeter http://j ...