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. C#中Invoke的用法1

    invoke和begininvoke 区别 一直对invoke和begininvoke的使用和概念比较混乱,这两天看了些资料,对这两个的用法和原理有了些新的认识和理解.  首先说下,invoke和be ...

  2. 调用 setState 之后发生了什么?

    (1)代码中调用 setState 函数之后,React 会将传入的参数对象与组件当前的状态合并,然后触发所谓的调和过程(Reconciliation).(2)经过调和过程,React 会以相对高效的 ...

  3. 每天一个linux命令(1):pwd命令

    1.命令简介 pwd(print work directory 打印当前目录)命令以绝对路径的方式显示用户当前工作目录. 2.用法 pwd [-LP] 3.选项 -L --logical 当目录为连接 ...

  4. JSOUP爬虫示例

    利用JSOUP做爬虫,爬取我博客中的所有标题加链接,代码示例如下: package com.test.jsoup; import java.io.IOException; import org.jso ...

  5. 基于Centos体验自然语言处理 by PHP SDK

    系统要求:CentOS 7.2 64 位操作系统 准备工作 获取 SecretId 和 SecretKey1 前往 密钥管理 页面获取你的 SecretId 和 SecretKey 信息,这些信息将会 ...

  6. 如何测试hello world

    最近在跟敏捷专家聊到了单元测试的相关内容. 我的问题主要集中在如何推广单元测试. 我们发现在很多团队,开发人员并不是十分愿意去写单元测试,我认为主要的原因是学习写单元测试是有成本的,很多开发同学并不愿 ...

  7. [svc]inotify+rsync解决nfs单点问题

    安装配置inotify 参考 yum install inotify* -y [root@n2 shell]# rpm -qa|grep inotify inotify-tools-3.14-8.el ...

  8. win10安装windows live writer 错误:OnCatalogResult:0x80190194

    到官网下载了一个在线安装程序,可是一运行就提示无法安装,显式错误"OnCatalogResult:0x80190194",如下图所示 找到windows live安装程序的安装日志 ...

  9. Oracle的NVL函数用法

    从两个表达式返回一个非 null 值. 语法 NVL(eExpression1, eExpression2) 参数eExpression1, eExpression2 如果 eExpression1 ...

  10. 【emWin】例程二十二:窗口对象——Framewin

    简介: 框架窗口为您的应用提供一个PC 应用程序的窗口外观.这些窗口由周围框架.标题栏和用户区组成. 触摸校准(上电可选择是否进入校准界面) 截图 实验指导书及代码包下载: 链接:http://pan ...