poj2136
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 16999 | Accepted: 8238 |
Description
Input
Output
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
#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的更多相关文章
- 【POJ2136】Vertical Histogram(简单模拟)
比较简单,按照样例模拟就好!~ #include <iostream> #include <cstdlib> #include <cstdio> #include ...
随机推荐
- Computer Transformation(hdoj 1041)
Problem Description A sequence consisting of one digit, the number 1 is initially written into a com ...
- SQL Server 内存使用量下降问题
SQL server这个程序是非喜欢内存这东西的.所以它的内存使用量下降,一定是被别人给抢去了.这件事的后果就是SQL Server 变的 非常慢.怎么样才可以让这件事不太容易发生呢? ------- ...
- vi全局替换方法
来自:http://blog.sina.com.cn/s/blog_736f1c59010136ry.html 1. 基本的替换 :s/vivian/sky/ 替换当前行第一个 vivian 为 sk ...
- VC++自绘界面
// MySkinDlg.cpp : implementation file // #include "stdafx.h" #include "MySkin.h" ...
- 我使用过的Linux命令之file - 检测并显示文件类型
摘自:http://codingstandards.iteye.com/blog/804463 我使用过的Linux命令之file - 检测并显示文件类型 用途说明 file命令是用来检测并显示文件类 ...
- Hibernate映射1
Hibernet映射 集合映射: 类的属性字段是集合的. set: <set name=”属性字段” table=“属性字段的表名”> <key 外键 column=“”> & ...
- Android(一)
Android Activity TextView,Button 1.在fragment_main.xml文件中直接添加控件 2.在MainActivity.java文件中添加TextView控件 在 ...
- golang之pkg(包)
一.概述 Golang拥有超过100个标准包(可用go list std |wc -l查看) 任何包系统设计的目的都是简化大型程序的设计和维护工作,通过将一组相关的特性放进一个独立的模块以便于理解和更 ...
- PipedInputStream/PipedOutputStream原理
PipedInputStream类与PipedOutputStream类用于在应用程序中创建管道通信.一个PipedInputStream实例对象必须和一个PipedOutputStream实例对象进 ...
- sql必知必会(第四版) 学习笔记一
温习一遍简单的sql语法,把自己掌握还不够的地方,做了些笔记.... 1 去重复关键词,distinct select distinct sname from student; 2 限制结果top的用 ...