Vertical Histogram
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 16999   Accepted: 8238

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<cstring>
#include<cstdio>
#include<iomanip>
using namespace std;
int main()
{
char str1[],str2[],str3[],str4[];
while(gets(str1))
{
gets(str2);
gets(str3);
gets(str4);
int number[];
int maxnum=;
memset(number,,sizeof(number)); //这句话一定要加上去,不要以为定义完数组后就会自动填充为0
for(int i=;i<strlen(str1);i++)
{
if(str1[i]==' '||str1[i]<'A'||str1[i]>'Z')
continue;
int j = (int)str1[i]-;
number[j]=number[j]+;
if(number[j]>maxnum)
maxnum = number[j];
}
for(int i=;i<strlen(str2);i++)
{
if(str2[i]==' '||str2[i]<'A'||str2[i]>'Z')
continue;
int j = (int)str2[i]-;
number[j]++;
if(number[j]>maxnum)
maxnum = number[j];
}
for(int i=;i<strlen(str3);i++)
{
if(str3[i]==' '||str3[i]<'A'||str3[i]>'Z')
continue;
int j = (int)str3[i]-;
number[j]++;
if(number[j]>maxnum)
maxnum = number[j];
}
for(int i=;i<strlen(str4);i++)
{
if(str4[i]==' '||str4[i]<'A'||str4[i]>'Z')
continue;
int j = (int)str4[i]-;
number[j]++;
if(number[j]>maxnum)
maxnum = number[j];
}
int temp = maxnum,flag=;
for(int j = ;j<temp;j++)
{
flag=;
for(int m=;m<;m++)
if(number[m]==maxnum)
{
flag = m;
}
for(int k =;k<;k++)
{ if(number[k]!=&&number[k]==maxnum)
{
if(flag==k)
{
printf("*");
number[k]--;
break;
}
else printf("* ");
number[k]--;
}
else
{
cout<<" ";
}
}
printf("\n");
maxnum--;
}
char c='A';
for(int i=;i<;i++)
printf("%c ",c++);
printf("%c\n",c); }
return ;
}

这题被搞的没心情了,很简单的一题,结果那个输出结果每一行最后一个星号后面不能有空格,弄的我wa半天,改写了各种代码,总是过不了,后来看了看了讨论区,有种想吐血的冲动。

poj2136的更多相关文章

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

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

随机推荐

  1. web开发(Java&Jquery)实现验证码

    1. Ajax Fancy Capcha 一个支持 Ajax 又很炫的 jQuery Captcha 插件,它使用了很人性化的验证机制. ​ from : http://www.webdesignbe ...

  2. JIRA官方:JIRA项目跟踪

    问题无处不在 使用JIRA来捕捉任何类型的问题——从软件缺陷到新特性到需求和故事到任务和活动项.你可以很方便地定义自己的问题类型以匹配团队工作需要. 自定义工作流 一个项目跟踪工具不应该决定你的工作方 ...

  3. 电子科大POJ "a^b"

    a ^ b Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) C-sources: ...

  4. 原生Javascript 省市区下拉列表插件

    每个电商网站中,都会有收件地址管理模块,用户进行地址操作时,最好不要用户手工进行填写地址. 常见的地址管理界面: 实现插件:PCASClass.js 插件下载地址:http://pan.baidu.c ...

  5. sriov查看pf-vf对应关系

    自己写的, 方便调试. $ cat pf-vf echo "physfn is $1"echo "pf info:"ls /sys/class/net/$1 - ...

  6. Makefile与Shell的问题

    http://blog.csdn.net/absurd/article/details/636418 Makefile与Shell的问题 大概只要知道Makefile的人,都知道Makefile可以调 ...

  7. iOS GCD详解

    前言 对初学者来说,GCD似乎是一道迈不过去的坎,很多人在同步.异步.串行.并行和死锁这几个名词的漩涡中渐渐放弃治疗.本文将使用图文表并茂的方式给大家形象地解释其中的原理和规律. 线程.任务和队列的概 ...

  8. Spark里面的任务调度:离SparkContext开始

    SparkContext这是发达国家Spark入学申请,它负责的相互作用和整个集群,它涉及到创建RDD.accumulators and broadcast variables.理解力Spark架构, ...

  9. IOS架构师之路:我对IOS架构的点点认识(大纲)

    1.今天我鼓起了勇气,想纪录自己对IOS架构学习成长的点点滴滴. 从事IOS开发也有几年的时间,从刚開始最主要的语言.界面.逻辑,再到后面复杂点的线程.数据处理.网络请求.动画,最后到最复杂的底层音视 ...

  10. 图片延迟加载并等比缩放,一个简单的JQuery插件

    使用方法: $(".viewArea img").zoom({height:74,width:103}); (function($){ $.fn.zoom = function(s ...