/**
 * ACM Training 2009
 * ACM Problem #706 - LCD Display
 * Link: http://uva.onlinejudge.org/external/7/706.html
 *
 * @author Felix Dietrich
 * @version 1.0, 09/21/2009
 *
 * Methode: String Manipulation
 * Status : Accepted
 * Runtime: 0.424
 */


import java.util.Scanner;


public class Main
{
    
    //
    //   0
    //5     1
    //   6
    //4     2
    //   3
    //
    
    static int[][] numbers={
        {0,1,2,3,4,5}, // zero
        {1,2}, // one
        {0,1,6,4,3}, // two
        {0,1,2,3,6}, // three
        {1,2,6,5}, // four
        {0,5,6,2,3}, // five
        {0,5,6,4,2,3}, // six
        {0,1,2}, // seven
        {0,1,2,3,4,5,6}, // eight
        {0,1,2,3,5,6} // nine
        };
    static int s;
    
    public static void main(String ...strs)
    {
        String number;
        
        Scanner sc = new Scanner(System.in);
        
        while(true)
        {
            s = sc.nextInt();
            number = sc.next();
            
            if(s == 0 && Integer.parseInt(number) == 0)
                return;

            StringBuffer sb = new StringBuffer("");
            for(int i=0; i<=2*s+2; i++)
            {
                for(char c: number.toCharArray())
                {
                    printCharLine(sb, c-'0', i);
                    append(sb, " ", 1);
                }

                sb.deleteCharAt(sb.length()-1);
                append(sb, "\n", 1);
            }
            System.out.println(sb.toString());
        }
    }

    /**
     * Prints one line of the given number in the given stringbuffer.
     * line sets the line of the number we should print.
     *
     * @param sb
     * @param n
     * @param line
     */
    private static void printCharLine(StringBuffer sb, int n, int line)
    {
        
        if(line == 0)
        {
            append(sb, " ", 1);
            if(contains(numbers[n], 0))
                append(sb, "-", s);
            else
                append(sb, " ", s);

            append(sb, " ", 1);
        }
        else if(line < s+1)
        {
                if(contains(numbers[n], 5))
                    append(sb, "|", 1);
                else
                    append(sb, " ", 1);
        
                append(sb, " ", s);
                
                if(contains(numbers[n], 1))
                    append(sb, "|", 1);
                else
                    append(sb, " ", 1);
        }
        else if(line == s+1)
        {
            append(sb, " ", 1);
            if(contains(numbers[n], 6))
                append(sb, "-", s);
            else
                append(sb, " ", s);
            append(sb, " ", 1);
        }
        
        else if(line < 2+2*s)
        {
            if(contains(numbers[n], 4))
                append(sb, "|", 1);
            else
                append(sb, " ", 1);
    
            append(sb, " ", s);
            
            if(contains(numbers[n], 2))
                append(sb, "|", 1);
            else
                append(sb, " ", 1);
        }
        else if(line == 2*s+2)
        {
            append(sb, " ", 1);
            if(contains(numbers[n], 3))
                append(sb, "-", s);
            else
                append(sb, " ", s);
            append(sb, " ", 1);
        }
    }

    /**
     * Appends s2 times the string string to sb
     * @param sb
     * @param string
     * @param s2
     */
    private static void append(StringBuffer sb, String string, int s2)
    {
        for(int i=0; i<s2; i++)
            sb.append(string);
    }

    /**
     * @param array array the element i should be in
     * @param i element to test
     * @return true if the given array contains the element i
     */
    private static boolean contains(int[] array, int i)
    {
        for(int element: array)
            if(element == i)
                return true;
        return false;
    }
}

2.


/* @Problem 706 LCD-Display
* @Autor Markus Stadler
* @Autor Johannes Müller


Runtime: 0.270
*/

import java.io.*;
import java.util.StringTokenizer;


class LCDiplay {
public static void main (String[] args) throws Exception {
BufferedReader buin = new BufferedReader (new InputStreamReader (System.in));
Writer out = new BufferedWriter(new PrintWriter(System.out));

int test = 1;
do {
String lines = buin.readLine();
StringTokenizer str = new StringTokenizer(lines);
int s = Integer.valueOf(str.nextToken());
String nstr = str.nextToken();
int n = Integer.valueOf(nstr);
if (s == n && s == 0)
test = 0;
int sign = 0;
sign = nstr.length();
int clength = (s+3)*sign; //array für gesammtes display
int height = 2*s+3;
char [][] display = new char [clength][height];
for (int line = 0; line < height; line++) {
for (int row = 0; row < clength; row++)
display[row][line] = ' ';
}
int length = s+2;
while(sign > 0) //(n > 0)
{
final int figure = n % 10; //Einerstelle isolieren

char [][] chr = new char [length][height]; //array für einzelne zahl
for (int line = 0; line < height; line++) {
for (int row = 0; row < length; row++)
chr[row][line] = ' ';
}
switch (figure){
case 0:
for (int c = 0; c < s; c++) //oben
chr [c+1][0] = '-';
for (int c = 0; c < s; c++) //links oben
chr [0][c+1] = '|';
for (int c = 0; c < s; c++) //rechts oben
chr [length-1][c+1] = '|';
for (int c = 0; c < s; c++) //links unten
chr [0][c+s+2] = '|';
for (int c = 0; c < s; c++) //rechts unten
chr [length-1][c+s+2] = '|';
for (int c = 0; c < s; c++) //unten
chr [c+1][2*s+2] = '-';
break;
case 1:
for (int c = 0; c < s; c++) //rechts oben
chr [length-1][c+1] = '|';
for (int c = 0; c < s; c++) //rechts unten
chr [length-1][c+s+2] = '|';
break;
case 2:
for (int c = 0; c < s; c++) //oben
chr [c+1][0] = '-';
for (int c = 0; c < s; c++) //rechts oben
chr [length-1][c+1] = '|';
for (int c = 0; c < s; c++) //mitte
chr [c+1][s+1] = '-';
for (int c = 0; c < s; c++) //links unten
chr [0][c+s+2] = '|';
for (int c = 0; c < s; c++) //unten
chr [c+1][2*s+2] = '-';
break;
case 3:
for (int c = 0; c < s; c++) //oben
chr [c+1][0] = '-';
for (int c = 0; c < s; c++) //rechts oben
chr [length-1][c+1] = '|';
for (int c = 0; c < s; c++) //mitte
chr [c+1][s+1] = '-';
for (int c = 0; c < s; c++) //rechts unten
chr [length-1][c+s+2] = '|';
for (int c = 0; c < s; c++) //unten
chr [c+1][2*s+2] = '-';
break;
case 4:
for (int c = 0; c < s; c++) //links oben
chr [0][c+1] = '|';
for (int c = 0; c < s; c++) //rechts oben
chr [length-1][c+1] = '|';
for (int c = 0; c < s; c++) //mitte
chr [c+1][s+1] = '-';
for (int c = 0; c < s; c++) //rechts unten
chr [length-1][c+s+2] = '|';
break;
case 5:
for (int c = 0; c < s; c++) //oben
chr [c+1][0] = '-';
for (int c = 0; c < s; c++) //links oben
chr [0][c+1] = '|';
for (int c = 0; c < s; c++) //mitte
chr [c+1][s+1] = '-';
for (int c = 0; c < s; c++) //rechts unten
chr [length-1][c+s+2] = '|';
for (int c = 0; c < s; c++) //unten
chr [c+1][2*s+2] = '-';
break;
case 6:
for (int c = 0; c < s; c++) //oben
chr [c+1][0] = '-';
for (int c = 0; c < s; c++) //links oben
chr [0][c+1] = '|';
for (int c = 0; c < s; c++) //mitte
chr [c+1][s+1] = '-';
for (int c = 0; c < s; c++) //links unten
chr [0][c+s+2] = '|';
for (int c = 0; c < s; c++) //rechts unten
chr [length-1][c+s+2] = '|';
for (int c = 0; c < s; c++) //unten
chr [c+1][2*s+2] = '-';
break;
case 7:
for (int c = 0; c < s; c++) //oben
chr [c+1][0] = '-';
for (int c = 0; c < s; c++) //rechts oben
chr [length-1][c+1] = '|';
for (int c = 0; c < s; c++) //rechts unten
chr [length-1][c+s+2] = '|';
break;
case 8:
for (int c = 0; c < s; c++) //oben
chr [c+1][0] = '-';
for (int c = 0; c < s; c++) //links oben
chr [0][c+1] = '|';
for (int c = 0; c < s; c++) //rechts oben
chr [length-1][c+1] = '|';
for (int c = 0; c < s; c++) //mitte
chr [c+1][s+1] = '-';
for (int c = 0; c < s; c++) //links unten
chr [0][c+s+2] = '|';
for (int c = 0; c < s; c++) //rechts unten
chr [length-1][c+s+2] = '|';
for (int c = 0; c < s; c++) //unten
chr [c+1][2*s+2] = '-';
break;
case 9:
for (int c = 0; c < s; c++) //oben
chr [c+1][0] = '-';
for (int c = 0; c < s; c++) //links oben
chr [0][c+1] = '|';
for (int c = 0; c < s; c++) //rechts oben
chr [length-1][c+1] = '|';
for (int c = 0; c < s; c++) //mitte
chr [c+1][s+1] = '-';
for (int c = 0; c < s; c++) //rechts unten
chr [length-1][c+s+2] = '|';
for (int c = 0; c < s; c++) //unten
chr [c+1][2*s+2] = '-';
break;
}
//chr array in display array
for (int line = 0; line < 2*s+3; line++) {
for (int row = 0; row < s + 2; row++){
display [row+(sign-1)*(s+3)][line] = chr [row][line];
}
}
sign--; //nächste zahl im ausgabearray eins nach links
n /= 10; //Restliche Ziffern um eine Position nach rechts
}
//output
if (test != 0){
for (int line = 0; line < 2*s+3; line++) { //fehler
for (int row = 0; row < clength-1; row++)
out.write(display[row][line]);

out.write("\n");
}
out.write("\n");
}
} while (test != 0);
out.close();
buin.close();
}
}



3.

/**
* ACM
* UVa Status: accepted
* Run Time: 0.260
* Category: ad hoc
* @author Evgeni Pavlidis evgenipavlidis@yahoo.de
*/
#include <iostream>
using namespace std;

static int s;
static int digits;
static string n;

static string space;
static string marked;

void printHead()
{
string result = " ";
for(int d=0; d<digits; d++)
{
if(n[d] != '1' && n[d] != '4')
result += marked;
else
result += space;

if(d < digits-1)
result += " ";
else
result += " ";
}

cout << result << endl;
}

void printUpperBody()
{
string result = "";
for(int d=0; d<digits; d++)
{
if(n[d] != '1' && n[d] != '2' && n[d] != '3' && n[d] != '7')
result += "|";
else
result += " ";

result += space;

if(n[d] < '5' || n[d] > '6')
result += "|";
else
result += " ";

if(d < digits-1)
result += " ";
}

cout << result << endl;
}

void printMiddle()
{
string result = " ";
for(int d=0; d<digits; d++)
{
if(n[d] != '1' && n[d] != '7' && n[d] != '0')
result += marked;
else
result += space;

if(d < digits-1)
result += " ";
else
result += " ";
}

cout << result << endl;
}

void printLowerBody()
{
string result = "";
for(int d=0; d<digits; d++)
{
if(n[d] == '2' || n[d] == '6' || n[d] == '8' || n[d] == '0')
result += "|";
else
result += " ";

result += space;

if(n[d] != '2')
result += "|";
else
result += " ";

if(d < digits-1)
result += " ";
}

cout << result << endl;
}

void printFeet()
{
string result = " ";
for(int d=0; d<digits; d++)
{
if(n[d] != '1' && n[d] != '4' && n[d] != '7')
result += marked;
else
result += space;

if(d < digits-1)
result += " ";
else
result += " ";
}

cout << result << endl;
}


int main()
{
while(true)
{
cin >> s;
if(s == 0)
return 0;
cin >> n;

digits = n.length();

space = "";
marked = "";
for(int i=0; i<s; i++)
{
space += " ";
marked += "-";
}

printHead();
for(int i=0; i < s; i++)
printUpperBody();
printMiddle();
for(int i=0; i < s; i++)
printLowerBody();
printFeet();

cout << endl;
}
}