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. Java第八天,抽象的概念是什么?如何完成抽象类的实现?

    抽象 面向对象编程中,抽象是一个很重要的概念,那么抽象有什么需要注意的地方呢?请熟记以下知识点. 如果父类当中的方法不确定如何进行方法体的实现,则这个方法就是抽象方法. 抽象方法只需要在方法前面加上a ...

  2. Flask入门 之 endpoint

    首先,要纠正两个错误! 1.flask是通过endpoint找到viewfunction(视图函数的),并不是通过路由直接找到viewfunction的. 2.是url_for(endpoint)而不 ...

  3. NonRegisteringDriver造成的内存频繁FullGc

    某天上服务器看了下gc情况,发现状况不对,启动了才2天的服务器发生了360次fullgc,这个频率肯定高了 说明 S0C.S1C.S0U.S1U:Survivor 0/1区容量(Capacity)和使 ...

  4. 数据结构篇-数组(TypeScript版+Java版)

    1.TypeScript版本 export default class MyArray<E> { public data: E[]; public size: number = 0; /* ...

  5. 条件变量 condition_variable wait

    wait(阻塞当前线程,直到条件变量被唤醒) #include <iostream> #include <string> #include <thread> #in ...

  6. golang trace 分析 简例

    今天,通过一个例子,一方面熟悉trace在自定义范围内的分析,另一方面golang 在协程调度策略上的浅析. Show Code // trace_example.go package main im ...

  7. Thinking in Java,Fourth Edition(Java 编程思想,第四版)学习笔记(十二)之Error Handling with Exceptions

    The ideal time to catch an error is at compile time, before you even try to run the program. However ...

  8. 45道SQL数据题详解1

    准备阶段: 创建表: //创建学生表,前面的s表示学生,相应的标签前面加t表示老师 CREATE TABLE students (sno VARCHAR(3) NOT NULL, sname VARC ...

  9. Delphi 文件操作(4)Reset

    procedure Reset(var F [: File; RecSize: Word ] );    { 作用:    对于文本文件,Reset过程将以只读方式打开文件,对于类型文件和无类型文件, ...

  10. JS 中的自定义事件和模拟事件

    在 JS 中模拟事件指的是模拟 JS 中定义的一些事件,例如点击事件,键盘事件等. 自定义事件指的是创建一个自定义的,JS 中之前没有的事件. 接下来分别说一下创建这两种事件的方法. 创建自定义事件 ...