#include <string>
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

string numbers[5][10]={
" - ", "   ", " - ", " - ", "   ", " - ", " - ", " - ", " - ", " - ",
"| |", "  |", "  |", "  |", "| |", "|  ", "|  ", "  |", "| |", "| |", 
"   ", "   ", " - ", " - ", " - ", " - ", " - ", "   ", " - ", " - ",
"| |", "  |", "|  ", "  |", "  |", "  |", "| |", "  |", "| |", "  |", 
" - ", "   ", " - ", " - ", "   ", " - ", " - ", "   ", " - ", " - ",
};

const int MAX_LEN=10;
int num[MAX_LEN];

//return number length
int fill_num(int n)
{
    memset(num, 0, sizeof(num));
    int i=0;
    do
    {
        num[i++]=n%10;
        n/=10;
    }while(n!=0);

reverse(num, num+i);
    return i;

}
void cout_a_row(int s, string n)
{
    cout<<n[0];
    for(int i=0;i<s;i++)
        cout<<n[1];
    cout<<n[2];
}

void print_num(int s, int n)
{

int len=fill_num(n);
    //cout<<len<<endl;

for(int row=0;row<(3+2*s);row++)
    {
        //输出各个数字的一行
        for(int i=0;i<len;i++)
        {
            int real_row;
            //head
            if(row==0)
            {
                real_row=0;
            }
            //head-mid
            if(row>0 && row<(3+2*s)/2)
            {
           
                real_row=1;
            }
            //mid
            if(row==(3+2*s)/2)
            {
                real_row=2;
            }
            if(row>(3+2*s)/2 && row<(3+2*s-1))
            {
                real_row=3;
            }
            //tail
            if(row==(3+2*s-1))
            {
                real_row=4;
            }
           
            cout_a_row(s, numbers[real_row][num[i]]);
            (i==len-1)?(cout<<endl):(cout<<" ");
        }
    }
    cout<<endl;
}

int main()
{
#if 0
    print_num(1, 1234567890);
    print_num(3, 1234567890);
    print_num(5, 1234567890);
    print_num(7, 1234567890);
#endif
    int s,num;
    while(cin>>s>>num, s||num)
    {
        print_num(s, num);
    }
    return 0;
}

PC/UVa 题号: 110104/706 LC-Display (液晶显示屏)题解的更多相关文章

  1. PC/UVa 题号: 110106/10033 Interpreter (解释器)题解 c语言版

    , '\n'); #include<cstdio> #include<iostream> #include<string> #include<algorith ...

  2. PC/UVa 题号: 110105/10267 Graphical Editor (图形化编辑器)题解

    #include<cstdio> #include<iostream> #include<string> #include<algorithm> #in ...

  3. PC/UVa 题号: 110101/100 The 3n+1 problem (3n+1 问题)

     The 3n + 1 problem  Background Problems in Computer Science are often classified as belonging to a ...

  4. uva题库爬取

    每次进uva都慢的要死,而且一步一步找到自己的那个题目简直要命. 于是,我想到做一个爬取uva题库,记录一下其中遇到的问题. 1.uva题目的链接是一个外部的,想要获取https资源,会报出SNIMi ...

  5. 天大acm 题号1002 Maya Calendar

    Description 上周末,M.A. Ya教授对古老的玛雅有了一个重大发现.从一个古老的节绳(玛雅人用于记事的工具)中,教授发现玛雅人使用了一个一年有365天的叫做Haab的历法.这 个Haab历 ...

  6. The Trip PC/UVa IDs: 110103/10137, Popularity: B, Success rate: average Level: 1

    #include<cstdio> #include<iostream> #include<string> #include<algorithm> #in ...

  7. hdu&&poj搜索题题号

    搜索 hdu1067 哈希 hdu1401 双向搜索 hdu1430 哈希 hdu1667 跌搜+启发式函数 hdu1685 启发式搜索 hdu1813 启发式搜索 hdu1885 状态压缩搜索 hd ...

  8. [Swust OJ 666]--初来乍到(题号都这么溜~~,递归,找规律)

    题目链接:http://acm.swust.edu.cn/problem/0666/ Time limit(ms): 1000 Memory limit(kb): 65535   Descriptio ...

  9. PAT DFS,BFS,Dijkstra 题号

    为什么要分类刷题: 因为刷⼀道算法题需要花⼀两个⼩时甚⾄半天,平时我们还要上课做别的事情,你在⼀段时间内刷算法如果只按照顺序,可能今天遇到了⼀道最短路径的题⽬,弄了半天好不容易看懂了别⼈的代码,以为⾃ ...

随机推荐

  1. RAID0_RAID1_RAID10_RAID5各需几块盘才可组建

    RAID 0 RAID 0即Data Stripping(数据分条技术).整个逻辑盘的数据是被分条(stripped)分布在多个物理磁盘上,可以并行读/写,提供最快的速度,但没有冗余能力.要求至少两个 ...

  2. https实现安全传输的流程

    HTTPS简介 HTTPS其实是有两部分组成:HTTP + SSL / TLS,也就是在HTTP上又加了一层处理加密信息的模块.服务端和客户端的信息传输都会通过TLS进行加密,所以传输的数据都是加密后 ...

  3. 【JSP】三种弹出对话框的用法实例

    对话框有三种 1:只是提醒,不能对脚本产生任何改变: 2:一般用于确认,返回 true 或者 false ,所以可以轻松用于 if...else...判断 3: 一个带输入的对话框,可以返回用户填入的 ...

  4. Delphi 2010 安装及调试

    呵呵,毫不客气地说,Delphi 2010 这个版本可以算是 Delphi 的一个“里程碑”,为什么这么说?因为这个版本实现了几个 Delphi 应该有却一直没有的功能 Delphi 2010 的新功 ...

  5. HDU 5114 Collision

    Collision Time Limit: 15000/15000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others) Total ...

  6. HDU 5742 It's All In The Mind

    It's All In The Mind Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

  7. Winform使用DevExpress的WaitDialogForm画面 z

    使用了DevExpress的WaitDialogForm 在应用程序加载开始时新建一个线程,并将loading画面show起来,在应用程序画面弹出前将该线程终止. 代码: private DevExp ...

  8. 转载:C语言的谜题

    转载:http://coolshell.cn/articles/945.html 这几天,本站推出了几篇关于C语言的很多文章如下所示: 语言的歧义 [酷壳链接] [CSDN链接] 谁说C语言很简单? ...

  9. bjfu1097 图标排列

    这是2011年百度之星的一道题.这题的做法就是找规律,规律找对了,代码极水.规律我一开始也没有找到,后来经人提醒,发现如下规律:对于每个开发者,其所有应用的分离度和一定是其第一个应用与最后一个应用的距 ...

  10. iOS 怎么样给自己的app打分呢?

    NSString *str =  [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@",@&quo ...