poj1102

模拟

#include <iostream>
#include <string>
using namespace std;

char numbers[10][5][3] = {
    {
        ' ', '-', ' ',
        '|', ' ', '|',
        ' ', ' ', ' ',
        '|', ' ', '|',
        ' ', '-', ' ',
    },
    {
        ' ', ' ', ' ',
        ' ', ' ', '|',
        ' ', ' ', ' ',
        ' ', ' ', '|',
        ' ', ' ', ' ',
    },
    {
        ' ', '-', ' ',
        ' ', ' ', '|',
        ' ', '-', ' ',
        '|', ' ', ' ',
        ' ', '-', ' ',
    },
    {
        ' ', '-', ' ',
        ' ', ' ', '|',
        ' ', '-', ' ',
        ' ', ' ', '|',
        ' ', '-', ' ',
    },
    {
        ' ', ' ', ' ',
        '|', ' ', '|',
        ' ', '-', ' ',
        ' ', ' ', '|',
        ' ', ' ', ' ',
    },
    {
        ' ', '-', ' ',
        '|', ' ', ' ',
        ' ', '-', ' ',
        ' ', ' ', '|',
        ' ', '-', ' ',
    },
    {
        ' ', '-', ' ',
        '|', ' ', ' ',
        ' ', '-', ' ',
        '|', ' ', '|',
        ' ', '-', ' ',
    },
    {
        ' ', '-', ' ',
        ' ', ' ', '|',
        ' ', ' ', ' ',
        ' ', ' ', '|',
        ' ', ' ', ' ',
    },
    {
        ' ', '-', ' ',
        '|', ' ', '|',
        ' ', '-', ' ',
        '|', ' ', '|',
        ' ', '-', ' ',
    },
    {
        ' ', '-', ' ',
        '|', ' ', '|',
        ' ', '-', ' ',
        ' ', ' ', '|',
        ' ', '-', ' ',
    }
};
int        size;

void print(int line, char *se)
{
    int        i, j;

    for (i = 0; i < strlen(se); i++)
    {
        cout << numbers[se[i] - '0'][line][0];
        for (j = 0; j < size; j++)
            cout << numbers[se[i] - '0'][line][1];
        cout << numbers[se[i] - '0'][line][2];
        cout << " ";
    }
    cout << endl;
}

void work()
{
    char    se[20];
    int        i;
    
    cin >> se;
    print(0, se);
    for (i = 0; i < size; i++)
        print(1, se);
    print(2, se);
    for (i = 0; i < size; i++)
        print(3, se);
    print(4, se);
    cout << endl;
}

int main()
{
    //freopen("t.txt", "r", stdin);
    while (cin >> size && size != 0)
        work();
    return 0;
}
View Code

 

posted @ 2013-07-19 20:00  金海峰  阅读(214)  评论(0编辑  收藏  举报