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. 命令行参数解析:getopt,getopt_long

    #include <unistd.h> int getopt(int argc, char * const argv[], const char *optstring); extern c ...

  2. 可以供MFC调用的,QT实现的DLL(qtwinmigrate实现)

    MFC和QT的消息循环机制不同,所以,要让QT写的DLL可以供MFC调用,要做一点特殊的处理 #include <qmfcapp.h> #include <qwinwidget.h& ...

  3. python 重要模块

    1,使用字典的特殊字符串替换,基于字典的字符串格式化

  4. VMware Workstation虚拟机使用ISO映像文件

    VMware Workstation虚拟机使用ISO映像文件 VMware Workstation虚拟机使用ISO映像文件

  5. KMP精讲

    KMP算法 —— next 数组的应用 --- 前缀中最小循环节,最大重复次数 在大神的基础上添加了一点自己的理解: 从图片中可以看出next数组中存的值就是最近一次最近一次循环节的下标... 在KM ...

  6. U盘量产的作用

    优盘量产:字面意思就是,批量生产优盘.是指批量对U盘主控芯片改写数据,如,写生产厂商信息.格式化等.而用来对U盘完成该操作的软件程序,顾名思义就是U盘量产工具.   U盘量产的作用:   电脑正确识别 ...

  7. SHUTDOWN: Active processes prevent shutdown operation

    在使用shutdown immediate关闭数据库时hang住,查看alert 日志,遭遇了SHUTDOWN: Active processes prevent shutdown operation ...

  8. 聚类算法初探(五)DBSCAN

    最近由于工作需要,对聚类算法做了一些相关的调研.现将搜集到的资料和自己对算法的一些理解整理如下,供大家参考. 另外在算法代码方面,我也做了一些实现(包括串行和并行),欢迎感兴趣的朋友探讨和交流. 第一 ...

  9. Time Out 访问数据库超时处理 .NET

    using System.Reflection; using System.Data.SqlClient; TransactionSelectTableAdapter adapter = new Tr ...

  10. 关于js对象值的传递

    结合红宝书和网上的一些文章,记录下自己对关于js对象的值的传递的一些理解. js对象是保存在堆内存中的,当把对象赋值给变量时,是把对象在堆内存的引用(地址)赋值给了变量,变量通过地址来访问对象.下面来 ...