poj 1102 LC-Display

来源:互联网 发布:js 获取contextpath 编辑:程序博客网 时间:2024/03/29 06:46
LC-Display
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 14432 Accepted: 5763

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 123453 678900 0

Sample Output

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

Source

Mid-Central European Regional Contest 1999

看完样例就知道什么意思了

#include <iostream>#include <cstring>using namespace std;char n1[] = "- -- -----";char n2[] = "|   ||| ||";char n3[] = "|||||  |||";char n4[] = "  ----- --";char n5[] = "| |   | | ";char n6[] = "|| |||||||";char n7[] = "- -- -- --";int main(){    int m;    char n[10];    while (cin>>m>>n,(n[0]-'0')||m)    {        int len = strlen(n);        for (int i=0; i<len; i++)        {            cout<<" ";            int num = n[i]-'0';            for (int j=0; j<m; j++)            {                cout<<n1[num];            }            cout<<"  ";        }        cout<<endl;        int temp = m;        while (temp--)        {            for (int i=0; i<len; i++)            {                int num = n[i]-'0';                cout<<n2[num];                for (int j=0; j<m; j++)                {                    cout<<" ";                }                cout<<n3[num];                cout<<" ";            }            cout<<endl;        }        for (int i=0; i<len; i++)        {            cout<<" ";            int num = n[i]-'0';            for (int j=0; j<m; j++)            {                cout<<n4[num];            }            cout<<"  ";        }        cout<<endl;        temp = m;        while (temp--)        {            for (int i=0; i<len; i++)            {                int num = n[i]-'0';                cout<<n5[num];                for (int j=0; j<m; j++)                {                    cout<<" ";                }                cout<<n6[num];                cout<<" ";            }            cout<<endl;        }        for (int i=0; i<len; i++)        {            cout<<" ";            int num = n[i]-'0';            for (int j=0; j<m; j++)            {                cout<<n7[num];            }            cout<<"  ";        }        cout<<endl<<endl;    }    return 0;}