您的位置:首页 > 其它

poj 1102 LC-Display

2013-09-12 20:22 274 查看
LC-Display

Time Limit: 1000MSMemory Limit: 10000K
Total Submissions: 14432Accepted: 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 12345
3 67890
0 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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: