#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. 系统性能监控之vmstat和iostat命令

    这篇文章主要介绍一些Linux性能检测相关的命令. vmstat和iostat的两个命令可以运行在主流的Linux/Unix操作系统上. 如果vmstat和iostat命令不能再你的电脑上运行,请安装 ...

  2. Android 使用库项目时的一个特殊tip

    前提: 项目A作为库项目被项目B引用,但是项目A中有自定义的控件和自定义的属性,当在项目B中使用自定义的属性时,编译时就会直接报错:No resource identifier found for a ...

  3. java 异常java.lang.UnsupportedOperationException

    在项目中采用一个枚举的集合,本人采用Collections中的空集合Collections.emptyList()在添加时发生异常: 常见集合如下: private List<VacationC ...

  4. DB2之隔离级别和锁的论述

    在DB2数据库中, 是通过行级锁和表级锁协调作用来提供较好的并发性, 同时保证数据库中数据的安全. 在DB2中缺省情况下使用行级锁(当然需要IS/IX锁配合),只有当出现锁资源不足, 或者是用命令指定 ...

  5. Oracle RAC环境下如何更新patch(Rolling Patch)

    Oracle RAC数据库环境与单实例数据库环境有很多共性,也有很多异性.对于数据库补丁的更新同样如此,都可以通过opatch来完成.但RAC环境的补丁更新有几种不同的更新方式,甚至于可以在零停机的情 ...

  6. Asp.Net MVC4 系列-- 进阶篇之路由(1)【转】

    http://blog.csdn.net/lan_liang/article/details/22993839?utm_source=tuicool

  7. Ios 程序封装,安装流程

    转:http://www.myexception.cn/operating-system/1436560.html Ios 程序打包,安装流程 一.发布测试,是指将你的程序给   * 你的测试人员,因 ...

  8. winfrom dataGridView 自定义分页实现

    Winfrom 基本处于忘光的阶段.先需要做个winfrom 的软件.然后自己扩展了DataGridView带分页的控件.废话不多说 上图先   现在一步步实现其效果. 1.添加用户控件 上图即可知道 ...

  9. 嵌入式 hi3518c平台网卡模式MII与RMII模式在Uboot和kernel中切换小结

    由于公司项目的需要,我们需要在原有的MII的基础上,修改为RMII模式,针对hi3518c平台,我的网卡是LAN8701需要修改的地方有如下几个: 首先我的uboot中env是: bootargs=m ...

  10. C#控制定位Word光标移动到任意行或者最后一行,取得光标位置等操作

    C#控制定位Word光标移动到任意行或者最后一行,取得光标位置等操作 http://blog.csdn.net/jglie/article/details/7394256 十一.上下左右移动光标位 p ...