POJ 2136 Vertical Histogram 水
来源:互联网 发布:莆田广电网络客服电话 编辑:程序博客网 时间:2024/05/09 07:01
Vertical Histogram
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 18152 Accepted: 8764Description
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 YOURHISTOGRAM 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
AC代码:
#include <iostream>#include <cstring>#include <cctype>#include <algorithm>using namespace std;int map[26];int maxc=-1,t;string a="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";void my(string in){ int len=in.length(); for(int i=0;i<len&&i<72;++i){ if(isupper(in[i])) map[(in[i]-65)]++; }}void fun(int i,int j){ int t=i+1; t=10-t; int ok=0; for(int k=j+1;k<26;++k)if(map[k]>maxc-i-1)ok=1; if(ok)cout<<" "; /*for(int k=j;k<26;++k){ if(map[k]>t){ cout<<" -"; return; } }*/}void fun2(int i,int j){ if(j<t){ cout<<' '; return; } int ok=0; for(int k=j+1;k<26;++k)if(map[k]>maxc-i-1)ok=1; if(ok)cout<<' ';}int main(){ string in[4]; memset(map,0,sizeof(map)); for(int i=0;i<4;++i){ getline(cin,in[i]); my(in[i]); } for(int i=0;i<26;++i) if(maxc<map[i]){ maxc=map[i]; t=i; } int h=maxc; for(int i=0,k=26;i<h;i++,k--){ for(int j=0;j<26;++j){ if(map[j]==maxc){ cout<<"*"; fun2(i,j); } else if(map[j]+i>=maxc){ cout<<"*"; fun2(i,j); } else if(j<t){ cout<<" "; fun2(i,j); } else fun(i,j); } cout<<'\12'; } cout<<a<<'\12'; /** for(int i=0;i<26;i++)cout<<map[i]<<' '; /**/ return 0;}
0 0
- POJ 2136 Vertical Histogram 水
- poj 2136 Vertical Histogram
- POJ 2136 Vertical Histogram
- POJ-2136 Vertical Histogram
- POJ 2136 Vertical Histogram
- POJ 2136 Vertical Histogram
- poj 2136 Vertical Histogram
- POJ 2136 Vertical Histogram G++
- poj 2136||ECUST 1004 Vertical Histogram
- poj 2136 Vertical Histogram (模拟)
- POJ 2136 Vertical Histogram(垂直直方图)
- POJ 2136 Vertical Histogram 打印特殊图形
- poj 2136.Vertical Histogram
- Vertical Histogram POJ
- PKU 2136 Vertical Histogram
- pku 2136 Vertical Histogram
- Vertical Histogram-2136
- POJ 2136 Vertical Histogram(我的水题之路——字符统计表)
- android如何获取以太网mac地址
- OgnlContext源码分析
- 对apk进行zipalign
- 【LIS 问题与 LCS 问题可以互相转换】
- UIScrollView, UIPageControl,UITableView
- POJ 2136 Vertical Histogram 水
- 用户投票算法
- Android、iPhone和Java三个平台一致的加密工具
- hdu2102(广搜)
- poj 2305 Basic remains java
- c++ opencv 数学函数示例
- HDOJ 2045 不容易系列之(3)—— LELE的RPG难题
- Openjudge6044 鸣人和佐助(bfs)
- Java类集学习小结