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# System.Collections.SortedList

    using System; using System.Collections; public class SamplesSortedList { public static void Main() { ...

  2. 70个注意的Python小Notes

    Python读书笔记:70个注意的小Notes 作者:白宁超 2018年7月9日10:58:18 摘要:在阅读python相关书籍中,对其进行简单的笔记纪要.旨在注意一些细节问题,在今后项目中灵活运用 ...

  3. rman输出日志的几种方法(转)

    在使用rman的时候经常会碰到以下两种场景,需要把rman的日志输出到文件中: 1.显示的日志太多,导致一个屏幕显示不完,影响了问题的诊断,这时候需要把rman的log输出到文本中,整个的诊断过程就相 ...

  4. JAVA四则运算字符串解释器

    最近学习到后缀表达式,于是基于后缀表达式的思想,写了一个四则运算解释器,输入字符串类型的四则运算表达式,可以直接得到结果,支持括号嵌套. 实现时主要考虑以下两点: 字符串中运算符和数字分离 运算符优先 ...

  5. jquery ajax IE

    在ie上会出现,get/post 只调用一次的现象 解决方法: cache:false http://stackoverflow.com/questions/8841425/how-to-set-ca ...

  6. CSA Enterprise Architecture图

    https://research.cloudsecurityalliance.org/tci/index.php/explore/

  7. 动软 生成 linq相关DAO

    第一步:新建自定义模板 <#@ template language="c#" HostSpecific="True" #> <#@ outpu ...

  8. 【Socket】关于socket长连接的心跳包

    TCP的socket本身就是长连接的,那么为什么还要心跳包呢? 在smack里有个30s发送一个空消息的线程,同样关于心跳包(keepalive) 据网络搜索到的资料解释如下 内网机器如果不主动向外发 ...

  9. Java四类八种数据类型

    http://www.cnblogs.com/simplefrog/archive/2012/07/15/2592011.html 第一类:逻辑型boolean 第二类:文本型char 第三类:整数型 ...

  10. Unity5 AssetBundle系列——资源加载卸载以及AssetBundleManifest的使用

    下面代码列出了对于assetbundle资源的常用操作,其中有针对bundle.asset.gameobject三种类型对象的操作,实际使用中尽量保证成对使用. 这一块的操作比较繁琐,但只要使用正确, ...