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

                            *
*
* *
* * * *
* * * *
* * * * * *
* * * * * * * * * *
* * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * 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

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

#include<iostream>
#include<map>
#include<cstring>
#include<cstdio>
#include<string>
using namespace std;
char a[100];
char b[100];
char c[100];
char d[100];
int ob[25];
int main()
{
int ans=0;
memset(ob,0,sizeof(ob));
gets(a);
gets(b);
gets(c);
gets(d);
for(int i=0;i<100;i++){
if(a[i]>='A'&&a[i]<='Z') ob[a[i]-'A'+1]++;
if(b[i]>='A'&&b[i]<='Z') ob[b[i]-'A'+1]++;
if(c[i]>='A'&&c[i]<='Z') ob[c[i]-'A'+1]++;
if(d[i]>='A'&&d[i]<='Z') ob[d[i]-'A'+1]++;
}
for(int i=0;i<=26;i++)
ans=max(ob[i],ans);
for(int i=ans;i>=1;i--){
for(int j=1;j<=26;j++)
if(ob[j]>=i)cout<<"* ";
else cout<<" ";
cout<<endl;
}
for(int j=0;j<=25;j++)
{
cout<<char(j+'A')<<' ';
}
}

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. Android视频悬浮窗口实现

    前言 本文例子实现了点击显示悬浮窗口,同时窗口可播放视频,拖动位置,点击关闭及返回APP页面,通过例子来讲述悬浮窗口实现原理及细节处理,效果图如下所示: 原理 WindowManager对View视图 ...

  2. 2017蓝桥杯算式900(C++C组)

    题目:算式900 小明的作业本上有道思考题:  看下面的算式:  (□□□□-□□□□)*□□=900  其中的小方块代表0~9的数字,这10个方块刚好包含了0~9中的所有数字.  注意:0不能作为某 ...

  3. python3(二十二) oop

    """ 面向对象编程 """ __author__ = 'shaozhiqi' # 面向对象的程序设计把计算机程序视为一组对象的集合,而每个 ...

  4. 从谷歌面试翻车到offer收割的心路历程

    首先声明,这只是我的播客随感,其中无法避免有一些个人色彩的见解,请不要在意,我尊敬任何的互联网公司,尊敬研究生期间的老师同学,我只希望给在求学路上的CS同学一些启发. 先介绍一下背景,我是ACM铜牌退 ...

  5. 逆拓扑排序 Reward HDU - 2647

    Reward HDU - 2647 题意:每个人的起始金额是888,有些人觉得自己做的比另一个人好所以应该多得一些钱,问最少需要花多少钱,如果不能满足所有员工的要求,输出 -1 样例1: 2 1 1 ...

  6. Linux c++ vim环境搭建系列(4)——vim插件安装配置使用

    4. 插件 主要是c++相关的. ~/.vimrc文件在GitHub上有:https://github.com/whuwzp/vim_config 以下内容参考: https://github.com ...

  7. 智能指针 unique_ptr

    unique_ptr 不共享它的指针.它无法复制到其他 unique_ptr,无法通过值传递到函数,也无法用于需要副本的任何标准模板库 (STL) 算法. 1.不能进行复制构造和赋值操作(unique ...

  8. Mybatis-项目结构

    源文件:https://github.com/569844962/Mybatis-Learn/blob/master/doc/Mybatis%E6%95%B4%E4%BD%93%E6%9E%B6%E6 ...

  9. Progress笔记

    1. iconv -f gbk -t unicode test.tmp > test.csv 如果出现文件数据补全,需要确认在这之前,output是否已经close,如果output to指定了 ...

  10. JSON Extractor(JSON提取器)

    JSON提取器 Variable names(名称):提取器的名称Apply to(应用范围):Main sample and sub-samples:应用于主sample及子sampleMain s ...