1.

/* @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();
}
}



2.
/**
* 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;
}
}