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. YouComplete:vim自动补全插件

    在github上下载插件,按照README.md安装 1,ubuntu安装 vim插件管理:vundle插件安装同样按照 README.md 操作 2,user guide General Usage ...

  2. Java与C#间json日期格式互转完美解决方案

    http://blog.csdn.net/wilsonke/article/details/24362851   作用一种简单方便的数据传输方案,JSON已经成为替代XML的事实标准.然而在JSON中 ...

  3. C 语言的可变参数表函数的设计

    在c语言中使用变长参数最常见的就是下面两个函数了: int printf(const char *format, ...); int scanf(const char *format, ...); 那 ...

  4. JTextPane 的 undo 、 redo

    实现文本框输入内容的单条记录撤销,重做,通过按钮实现 以及通过JList的多条撤销.重做操作(类似PS) 昨天还在为自己写不出代码怎么办而伤心,没想到今天上午就实现了,并且还完善了功能: 可以在撤销一 ...

  5. zookeeper数据弱一致性

    zookeeper本身支持单机部署和集群部署,生产环境建议使用集群部署,因为集群部署不存在单点故障问题,并且zookeeper建议部署的节点个数为奇数个,只有超过一半的机器不可用整个zk集群才不可用. ...

  6. Linux脚本练习

    例1:写一个脚本,利用循环和continue关键字,计算100以内能被3整除的数之和 运行结果: 例2: 写一个脚本,利用循环和continue关键字,计算100以内能被3整除的数之和 运行结果: 例 ...

  7. Endian.BIG_ENDIAN和Endian.LITTLE_ENDIAN(http://smartblack.iteye.com/blog/1129097)

    Endian.BIG_ENDIAN和Endian.LITTLE_ENDIAN 在ByteArray和Socket中,能看到一个属性endain. endian : String 更改或读取数据的字节顺 ...

  8. 依赖注入及AOP简述(九)——单例和无状态Scope .

    三.依赖注入对象的Scope及其生命周期 在前面的章节我们讲到,依赖注入容器之所以能够区别于以往的ServiceLocator等容器,是在于其不但能够自动构建多层次的.完整的依赖关系图,并且可以管理依 ...

  9. sublime安装和汉化

    对程序员来说,在不同的平台下有不同的IDE,网上很多教程都是使用DW,以致DW大名鼎鼎.其实,还有一些我们不为熟知的,却超级牛X的编辑器,我相信Sublime Text就是其中之一. 官方下载地址:h ...

  10. VMware虚拟机中调整Linux分区大小手记(转发)

      前段时间用VMware5.5安装了CentOS5.3,安装的时候分配了5Gb的虚拟硬盘空间给Linux系统,系统安装选择很多组件和软件,后面使用时又安装也一些软件,结果导致虚拟硬盘空间不足.查看分 ...