#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. LeetCode: Next Permutation & Permutations1,2

    Title: Implement next permutation, which rearranges numbers into the lexicographically next greater ...

  2. 使用ffmpeg实现转码样例(代码实现)

    分类: C/C++ 使用ffmpeg实现转码样例(代码实现) 使用ffmpeg转码主要工作如下: Demux -> Decoding -> Encoding -> Muxing 其中 ...

  3. HTTP请求中浏览器缓存

    本文导读:浏览器缓存机制,其实主要就是HTTP协议定义的缓存机制.客户端缓存是否需要是可以在服务端代码上控制的.那就是响应头.响应头告诉缓存器不要保留缓存,缓存器就不会缓存相应内容:如果请求信息是需要 ...

  4. ANDROID开发之SQLite详解

    本文转自:http://www.cnblogs.com/Excellent/archive/2011/11/19/2254888.html

  5. Ecshop文件结构,二次开发

    文件结构,二次开发有用 ECShop 2.6.2 的结构图及各文件相应功能介绍 ECShop2.6.2 upload 的目录 ┣ activity.php 优惠活动列表 ┣ affiche.php 广 ...

  6. Asp.net TextBox常规输入验证

    Asp.net TextBox只能输入数字<asp:textbox id="TextBox1" onkeyup="if(isNaN(value))execComma ...

  7. Java每日一则-001

    Java中类名与文件名的关系 1.Java保存的文件名必须与类名一致: 2.如果文件中只有一个类,文件名必须与类名一致: 3.一个Java文件中只能有一个public类: 4.如果文件中不止一个类,文 ...

  8. 利用phantomjs模拟QQ自动登录

    之前为了抓取兴趣部落里的数据,研究了下QQ自动登录. 当时搜索了一番,发现大部分方法都已经失效了,于是准备自己开搞. 第一个想到的就是参考网上已有方案的做法,梳理登陆js的实现,通过其他语言重写.考虑 ...

  9. hdu 2824 The Euler function

    The Euler function Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  10. C#中的表达式树简介

    表达式树是.NET 3.5之后引入的,它是一个强大灵活的工具(比如用在LINQ中构造动态查询). 先来看看Expression类的API接口: using System.Collections.Obj ...