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. Android小记之--android:listSelector

    使用ListView和GridView时,经常使用android:listSelector来使item被选中时的状态.但如果不配合android:drawSelectorOnTop来使用可能达不到想要 ...

  2. 最核心4大NFC技术规范详解

    1998年,飞利浦.索尼和诺基亚创建了 NFC论坛,宗旨是推动NFC的发展普及和规范化.论坛至今共推出了5大类技术规范:协议技术规范(Protocol Technical Specification) ...

  3. mybatis数据库数据分页问题

    http://www.cnblogs.com/jcli/archive/2011/08/09/2132222.html 借花献佛,天天进步

  4. (十)boost库之多线程

    (十)boost库之多线程 1.创建线程 使用boost库可以方便的创建一个线程,并提供最多支持9个参数的线程函数,相对于void*来说,方便了很多,创建线程主要提供了一下3种方式: 线程库头文件:# ...

  5. 最少步数(dfs + bfs +bfs优化)

    最少步数 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 这有一个迷宫,有0~8行和0~8列: 1,1,1,1,1,1,1,1,1 1,0,0,1,0,0,1,0,1 ...

  6. jquery获取父窗口的元素[转]

    $("#父窗口元素ID",window.parent.document); 对应javascript版本为window.parent.document.getElementById ...

  7. C# 泛型转换 将object[] 数组转换为泛型列表

    public List<TaskSoftInfo> ReadSoftDownTaskList()        {                string[] Tid = (strin ...

  8. ParNew收集器

    ParNew收集器其实就是Serial收集器的多线程版本,除了使用多条线程进行垃圾收集之外,其余行为包括Serial收集器可用的所有控制参数,其中Par是Paralle简写l 并行(Parallel) ...

  9. 为什么Underscore

    Underscore是什么? Underscore一个JavaScript实用库,提供了一整套函数式编程的实用功能,但是没有扩展任何JavaScript内置对象.它是这个问题的答案:“如果我在一个空白 ...

  10. (原) Jquery 判断设备是PC端,还是移动端

    判断设备是PC端,还是移动端 var ua = navigator.userAgent.toLocaleLowerCase(); var pf = navigator.platform.toLocal ...