HDU2708-模拟题
来源:互联网 发布:jav网络机顶盒怎么样 编辑:程序博客网 时间:2024/05/29 06:52
Vertical Histogram
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1598 Accepted Submission(s): 284
Problem 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 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
Source
USACO 2003 February Orange
题意:
题目意思很明确,给定四组字符串,让你统计四组字符串中每个字符的出现次数,然后,按照样例的格式输出。
PS:
1.输入样例有多组。
2.需要忽略最后一个‘*’的后导空格。
3.每列之间空一个空格。
接下来就是耐心敲代码了。
#include <iostream>#include <string>using namespace std;int letter[300];char str[300],map[300][300];int main(){#ifndef ONLINE_JUDGEfreopen("2.txt","r",stdin);#endifint i,j;while (gets(str))//read four line at one time{memset(letter,0,sizeof letter);for (j=0; str[j]; ++j){if (isupper(str[j]))++letter[str[j]-'A'];}for (i=0; i < 3; ++i){gets(str);for (j=0; str[j]; ++j){if (isupper(str[j]))++letter[str[j]-'A'];}}//end readmemset(map,' ',sizeof map);for (j=0; j < 26; ++j)//calculate how many time letter appears{for (; letter[j] > 0; --letter[j]){map[letter[j]][j+j] = '*';}}for (i=1; ; ++i)//ignore the ending spaces{for (j=52; j >= 0; --j){if (map[i][j] == '*'){map[i][j+1] = '\0';break;}}if (j < 0)break;}while (--i)puts(map[i]);puts("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");}return 0;}
0 0
- HDU2708-模拟题
- hdu2708
- hdu2708
- HDU2708 Vertical Histogram
- 模拟题
- 模拟题
- 模拟题
- nyoj 1187 模拟2048 (模拟题)
- 【NOIP 模拟题】[T1]return(模拟)
- [NOIP模拟题][模拟][DP][乱搞]
- NOIP模拟题 [模拟][DP][线段树]
- scjp的模拟题
- 面试模拟题3
- 面试模拟题4
- 面试模拟题5
- Poj 模拟题
- hdoj1008(模拟题)
- 汇编语言程序设计模拟题
- 【数据结构】堆排序
- Android-StageFright之数据流的封装和AwesomePlayer流程
- 偶遇一种复制内容到剪贴板的工具
- Python类、模块、包
- C++11中值得关注的几大变化
- HDU2708-模拟题
- Zepto.js
- 数据结构之约瑟夫问题---猴子选大王
- JS实现文件下载
- 逢年过节了。好热闹呢
- plsql工具比较用户对象
- 七堇年《生如夏花》
- wget gzip
- vi命令的一些用法