J - Vertical Histogram(1.5.7)

Time Limit:1000MS    Memory Limit:65536KB    64bit IO Format:%I64d
& %I64u

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
#include<iostream>
#include <cstdio>
#include <ctype.h>
#include<string>
using namespace std;
int main()
{
int cnt[30],max=-1;
int i,j;
memset(cnt,0,sizeof(cnt));
for(i=0;i<4;i++)
{
string s;
getline(cin,s);
for(j=0;j!=s.size();j++)
if(isupper(s[j])) //判断是否为大写字母
cnt[s[j]-'A']++;
}
for(i=0;i<26;i++)
if(cnt[i]>max)
max=cnt[i];//max记录的是出现最多的字母的个数
for(i=max;i>0;i--)
{
for(j=0;j<26;j++)
if(cnt[j]>=i)
printf("* ");
else printf(" ");
puts("");
}
for(i=0;i<26;i++)
printf("%c ",'A'+i);
puts("");
return 0;
}

J - Vertical Histogram(1.5.7)的更多相关文章

  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(当时写的比较恶心,优化一下)

    Vertical Histogram Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21223 Accepted: 10048 ...

  3. poj 2136 Vertical Histogram 解题报告

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

  4. POJ 2136 Vertical Histogram

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

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

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

  6. POJ 题目分类(转载)

    Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...

  7. (转)POJ题目分类

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

  8. poj分类

    初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      ( ...

  9. 转载 ACM训练计划

    leetcode代码 利用堆栈:http://oj.leetcode.com/problems/evaluate-reverse-polish-notation/http://oj.leetcode. ...

随机推荐

  1. SQL Server连接错误1326

    全新的SQL Server 2017,在2018年末才安装上,不过使用它来管理并不复杂的几张表,占用相对较多服务器资源,确实是有些大材小用. 无论如何,安装还是比较顺利.记得2012年第一次安装SQL ...

  2. C# System.IO.File

    using System; using System.IO; class Test { public static void Main() { string path = @"c:\temp ...

  3. RescuePro Deluxe恢复软件SanDisk

      RescuePro Deluxe恢复软件 注册码:RPDLX-0600-67844-04261-27951 买硬盘送的,没有用.   文章来源:刘俊涛的博客 欢迎关注,有问题一起学习欢迎留言.评论

  4. BaseDAO使用

    BaseDao接口的过人之处在于:一般是提供从数据库 增加.删除.修改记录.查询所有记录.查询符合某个条件记录.取得某条记录等方法的底层数据操作自定义类.由于我们可能操作多个数据库表,这样就需要为每个 ...

  5. Ubuntu下搭建tftp服务器最简单方法

    今天开始调试ARM的板子,要通过tftp下载到板子上,所以又要配置tftp服务器,真的烦死了… (本人酷爱装系统,所以经常都要搞配置) 因为之前已经在Ubuntu下搭建过很多次tftp服务器了,但是一 ...

  6. Vue中CSS模块化最佳实践

    Vue风格指南中介绍了单文件组件中的Style是必须要有作用域的,否则组件之间可能相互影响,造成难以调试. 在Vue Loader Scope CSS和Vue Loader CSS Modules两节 ...

  7. springboot 中打印 sql 语句

    在配置文件中 application.yml 配置如下其一即可 方式一: logging: level: com.xxx.com.dao.mapper: DEBUG //包路径为mapper文件包路径 ...

  8. 2.Swift快速浏览

    传统认为,在一个新的语言的第一个程序要在屏幕上显示“Hello world!”.在Swift,可以用一行代码来完成: println("Hello, world!") 如果你已经在 ...

  9. (Java编程思想)Thinking in Java

    1. 为什么突然想去研读<Thinking in Java>? 最近终于下定决心撸了一本<Thinking in Java>第四版,虽然在此之前我就久闻这本书的大名,但一直未曾 ...

  10. 在webpack中使用postcss-px2rem的

    经过一番折腾重要搞定了. 首先需要安装postcss-plugin-px2rem. npm install --save-dev postcss-plugin-px2rem 我的webpack工程中没 ...