1.6.4 液晶显示屏 LC-Display


PC/UVA 110104/704

本题。只需要模拟即可

//author: CHC
//First Edit Time:	2014-01-11 12:58
//Last Edit Time:	2014-01-11 13:47
//Filename:1.cpp
#include <iostream>
#include <cstdio>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
int s,n,len;
char temp[1000];
char tt[]="---------------------------------";
void print(int i)
{
    for(int j=0;j<len;j++)
    {
        int num=temp[j]-'0';
        if(num==0)
        {
            if(i==0)
                printf("%*s",s+2,"");
            else if(abs(i)!=s+1)
                printf("|%*s|",s,"");
            else
                printf(" %.*s ",s,tt);
        }
        else if(num==1)
        {
            if(abs(i)!=s+1&&i!=0) printf("%*s",s+2,"|");
            else printf("%*s",s+2,"");
        }
        else if(num==2)
        {
            if(i==0||abs(i)==s+1) printf(" %.*s ",s,tt);
            else if(i<0) printf("%*s|",s+1,"");
            else printf("|%*s",s+1,"");
        }
        else if(num==3)
        {
            if(abs(i)==s+1||i==0) printf(" %.*s ",s,tt);
            else printf("%*s",s+2,"|");
        }
        else if(num==4)
        {
            if(abs(i)==s+1)printf("%*s",s+2,"");
            else if(i==0)printf(" %.*s ",s,tt);
            else if(i<0)printf("|%*s|",s,"");
            else printf("%*s",s+2,"|");
        }
        else if(num==5)
        {
            if(abs(i)==s+1||i==0)printf(" %.*s ",s,tt);
            else if(i<0)printf("|%*s",s+1,"");
            else if(i>0)printf("%*s|",s+1,"");
        }
        else if(num==6)
        {
            if(abs(i)==s+1||i==0)printf(" %.*s ",s,tt);
            else if(i<0)printf("|%*s",s+1,"");
            else printf("|%*s|",s,"");
        }
        else if(num==7)
        {
            if(i==-s-1)printf(" %.*s ",s,tt);
            else if(i==0||i==s+1)printf("%*s",s+2,"");
            else printf("%*s|",s+1,"");
        }
        else if(num==8)
        {
            if(abs(i)==s+1||i==0) printf(" %.*s ",s,tt);
            else printf("|%*s|",s,"");
        }
        else if(num==9)
        {
            if(abs(i)==s+1||i==0)printf(" %.*s ",s,tt);
            else if(i<0)printf("|%*s|",s,"");
            else printf("%*s",s+2,"|");
        }
        if(j!=len-1)putchar(' ');
    }
}
int main()
{
    while(~scanf("%d%d",&s,&n)&&(s||n))
    {
        sprintf(temp,"%d",n);
        len=strlen(temp);
        for(int i=-s-1;i<=s+1;i++,puts(""))
        {
            print(i);
        }
        puts("");
    }
    return 0;
}



LC-Display

 

A friend of yours has just bought a new computer. Before this, the most powerful machine he ever used was a pocket calculator. He is a little disappointed because he liked the LCD display of his calculator more than the screen on his new computer! To make him happy, write a program that prints numbers in LCD display style.

Input

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

Output

Print the numbers specified in the input file in an LCD 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, including the last digit. There must be exactly one column of blanks between two digits.

Output a blank line after each number. You will find an example of each digit in the sample output below.

Sample Input

2 12345
3 67890
0 0

Sample Output

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

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值