poj 1102 LC-Display(模拟)

网友投稿 617 2022-08-27

poj 1102 LC-Display(模拟)

poj 1102 LC-Display(模拟)

题目:​​class="data-table" data-id="t7a7e9d1-l3U6hflY" data-transient-attributes="class" data-width="1162px" style="width: 100%; outline: none; border-collapse: collapse;">

Time Limit: 1000MS

 

Memory Limit: 10000K

Total Submissions: 15752

 

Accepted: 6291

Description

A friend of you has just bought a new computer. Until now, the most powerful computer he ever used has been a pocket calculator. Now, looking at his new computer, he is a bit disappointed, because he liked the LC-display of his calculator so much. So you decide to write a program that displays numbers in an LC-display-like style on his computer.

Input

The input contains several lines, one for each number to be displayed. Each line contains two integers s, n (1 <= s <= 10, 0 <= n <= 99 999 999), where n is the number to be displayed and s is the size in which it shall be displayed.  The input file will be terminated by a line containing two zeros. This line should not be processed.

Output

Output the numbers given in the input file in an LC-display-style using s "-" signs for the horizontal segments and s "|" signs for the vertical ones. Each digit occupies exactly s+2 columns and 2s+3 rows. (Be sure to fill all the white space occupied by the digits with blanks, also for the last digit.) There has to be exactly one column of blanks between two digits.  Output a blank line after each number. (You will find a sample of each digit in the sample output.)

Sample Input

2 12345 3 67890 0 0

Sample Output

-- -- -- | | | | | | | | | | | | -- -- -- -- | | | | | | | | | | -- -- -- --- --- --- --- --- | | | | | | | | | | | | | | | | | | | | | | | | --- --- --- | | | | | | | | | | | | | | | | | | | | | | | | --- --- --- ---

分析:是的,这就是一道模拟题,仅此而已。需要细心。我是先把8按照尺寸要求写出来,然后其他数字再在8的基础上抹去某些笔画,再保存该数字。

解题时我干了一件用时间换空间的傻事,n<1e9的,顶多8位数,我神乎其神的误认为保存结果的话需要1e9的数组空间,||-_- 是一维为9的空间!下面的代码数组直接二维,没有保存所有的数字信息,写出一个数字print一部分,这时间浪费的啊。。还好过了。。

#include #include #include using namespace std;int s;char n[20],eight[35][20],str[35][20];void printblank(){ for(int i=0;i<2*s+3;i++) printf(" \n");}void createight(){ memset(eight,0,sizeof(eight)); eight[0][0]=' '; for(int j=1;j>s>>n){ if(s==0&&n[0]=='0') break; createight(); int length=strlen(n); int i,j,k; for(i=0;i<2*s+3;i++){ for(k=0;k

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:poj 1823 Hotel(线段树·区间更新·lazy tag)
下一篇:13 种编程语言名称的来历
相关文章

 发表评论

暂时没有评论,来抢沙发吧~