#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. webapp调试工具weinre的使用

    在设计师与前端开发人员的努力下,一个WebApp出炉了,可是测试人员说了一堆的问题:某某机型下页面表现不一致,某某系统下页面如何如何,某某 系统浏览器下页面怎么怎么滴.看着满满的测试汇总文档,我们曾经 ...

  2. ffmpeg+rtsp+dss

    1. push stream to dss ffmpeg -f mpegts -re -i film.v -c:v libx264 -s 352x288 -aspect 4:3 -b:v 300k - ...

  3. 保护眼睛,开启浏览器的夜间模式 顺便学下!important的作用

    打开笔记本程序,复制以下代码 *{background-image: none !important; background: none !important; background:#333333 ...

  4. ECSHOP - 二次开发指南---购物车篇

    第一个问题 保存用户购物车数据ECSHOP的购物车数据,是以Session 方式存储在数据库里,并在Session结束后 ,Distroy 掉,解决方法是: 1.购物车内容读取方式. 更改登陆后购物车 ...

  5. SQL之50个常用的SQL语句

    50个常用的sql语句 Student(S#,Sname,Sage,Ssex) 学生表 Course(C#,Cname,T#) 课程表 SC(S#,C#,score) 成绩表 Teacher(T#,T ...

  6. IOS 多级列表展开控件

    项目中实现了一个可以多级展开的列表控件.每次展开都是互斥的,就是说,展开一个cell 就会关闭其他展开的层. 可以呈现的效果如下图.第一个图片是应用中实现的效果.第二个是Demo中的效果.如果有新的需 ...

  7. hdu 3341(ac自动机+状态压缩)

    题意:容易理解... 思路:首先一开始容易想到要用到dp,开设一个dp[41][41][41][41][501]的数组来解决,但是明显内存已经超出范围了,于是就想如何减少内存呢?只要知道A.T.C.G ...

  8. SQL删除数据库里所有表的外键,同时删除所有用户表

    SQL删除数据库里所有表的外键,同时删除所有用户表 删除所有的用户表的外键,直接将下面的代码拷贝到数据库里执行即可: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...

  9. Matlab编程实例(4) 相位角与相关系数曲线

    %相位角与相关系数曲线 close all; clear all; Samp1=200;  %设置信号的采样精度 Samp2=200;  %设置相位角p分割精度 A=10;%信号幅值 w=1;%信号角 ...

  10. HDU 1536 sg-NIM博弈类

    题意:每次可以选择n种操作,玩m次,问谁必胜.c堆,每堆数量告诉. 题意:sg—NIM系列博弈模板题 把每堆看成一个点,求该点的sg值,异或每堆sg值. 将多维转化成一维,性质与原始NIM博弈一样. ...