1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS10/11
* Problem: 706 LC-Display
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=9&page=show_problem&problem=647
*
* @author Patrick Bédat
* @author Christoph Göttschkes
* @version 1.0, 10/20/2010
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.460
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
private static boolean[][] segments;

public static void main(String... args) throws IOException
{
segments = new boolean[10][7];

segments[0] = new boolean[]
{
true, true, true, true, true, true, false
};
segments[1] = new boolean[]
{
false, true, true, false, false, false, false
};
segments[2] = new boolean[]
{
true, true, false, true, true, false, true
};
segments[3] = new boolean[]
{
true, true, true, true, false, false, true
};
segments[4] = new boolean[]
{
false, true, true, false, false, true, true
};
segments[5] = new boolean[]
{
true, false, true, true, false, true, true
};
segments[6] = new boolean[]
{
true, false, true, true, true, true, true
};
segments[7] = new boolean[]
{
true, true, true, false, false, false, false
};
segments[8] = new boolean[]
{
true, true, true, true, true, true, true
};
segments[9] = new boolean[]
{
true, true, true, true, false, true, true
};

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

int size = -1;
int number = -1;

StringTokenizer st = new StringTokenizer(reader.readLine());
size = Integer.parseInt(st.nextToken());
number = Integer.parseInt(st.nextToken());

while (size != 0)
{
StringBuilder sb;

int[] digits;

if(number == 0)
digits = new int[]{0};
else
digits = numberToDigits(number);

//line1
sb = drawHorizontalSegments(digits, size, 0);

//line2
StringBuilder sbTemp = drawVerticalSegments(digits, size, 5, 1);

for (int i = 0; i < size; i++)
sb.append(sbTemp);

//line4
sb.append(drawHorizontalSegments(digits, size, 6));

//line5
sbTemp = drawVerticalSegments(digits, size, 4, 2);

for (int i = 0; i < size; i++)
sb.append(sbTemp);

sb.append(drawHorizontalSegments(digits, size, 3));

st = new StringTokenizer(reader.readLine());
size = Integer.parseInt(st.nextToken());
number = Integer.parseInt(st.nextToken());

System.out.println(sb);
}
}

private static StringBuilder drawHorizontalSegments(int[] digits, int size, int segmentFunction)
{
StringBuilder sb = new StringBuilder();

for (int digit : digits)
{
sb.append(" ");
for (int i = 0; i < size; i++)
if (segments[digit][segmentFunction])
sb.append("-");
else
sb.append(" ");
sb.append(" ");
}
sb.deleteCharAt(sb.length() - 1);
sb.append(System.getProperty("line.separator"));

return sb;
}

private static StringBuilder drawVerticalSegments(int[] digits, int size, int segmentFunctionLeft, int segmentFunctionRight)
{
StringBuilder sb = new StringBuilder();

for (int digit : digits)
{
if (segments[digit][segmentFunctionLeft])
sb.append("|");
else
sb.append(" ");

for (int i = 0; i < size; i++)
sb.append(" ");

if (segments[digit][segmentFunctionRight])
sb.append("|");
else
sb.append(" ");

sb.append(" ");
}

sb.deleteCharAt(sb.length() - 1);
sb.append(System.getProperty("line.separator"));

return sb;
}

private static int[] numberToDigits(int number)
{
int numberLength = (int) Math.floor(Math.log10(number) + 1);
int[] digits = new int[numberLength];

for (int i = 0; i < numberLength; i++)
{
digits[numberLength - i - 1] = number % 10;
number /= 10;
}

return digits;
}
}


2.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS2010
* Problem: 706 - LCDisplay
* Link: http://uva.onlinejudge.org/external/7/706.pdf
*
* @author Barny Porcio
* @version 1.0, 04/21/2010
*
* Status : Accepted
* Runtime: 1.304
*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main{

public static void main(String[] args) throws IOException {
// oben: 0; ob.rech: 1 ; un.rech: 2 ; unten: 3; un.lin: 4 ; ob.lin: 5 ; mitte: 6
boolean[][] figtures = new boolean[10][7];
figtures[0][0] = true; figtures[0][1] = true; figtures[0][2] = true; figtures[0][3] = true; figtures[0][4] = true; figtures[0][5] = true;
figtures[1][1] = true;figtures[1][2] = true;
figtures[2][0] = true; figtures[2][1] = true; figtures[2][3] = true; figtures[2][4] = true;figtures[2][6] = true;
figtures[3][0] = true;figtures[3][1] = true;figtures[3][2] = true;figtures[3][3] = true;figtures[3][6] = true;
figtures[4][1] = true;figtures[4][2] = true; figtures[4][5] = true; figtures[4][6] = true;
figtures[5][0] = true; figtures[5][2] = true; figtures[5][3] = true; figtures[5][5] = true; figtures[5][6] = true;
figtures[6][0] = true;figtures[6][2] = true;figtures[6][3] = true;figtures[6][4] = true;figtures[6][5] = true;figtures[6][6] = true;
figtures[7][0] = true; figtures[7][1] = true; figtures[7][2] = true;
figtures[8][0] = true;figtures[8][1] = true;figtures[8][2] = true;figtures[8][3] = true;figtures[8][4] = true;figtures[8][5] = true;figtures[8][6] = true;
figtures[9][0] = true;figtures[9][1] = true;figtures[9][2] = true;figtures[9][3] = true;figtures[9][5] = true;figtures[9][6] = true;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int size = Integer.parseInt(st.nextToken());
String num = st.nextToken();
int number = Integer.parseInt(num);
boolean first = true;
while (!(size == 0 && number == 0)){
if (first)
first = false;
else
System.out.println();
for (int heigh = 0; heigh < 5; ++heigh){
StringBuilder sb = new StringBuilder();

for (int digits = 0; digits < num.length(); ++digits){
int temp = num.charAt(digits)-48;
switch (heigh) {
case 0:
System.out.print(' ');
for (int widerho = 0; widerho < size ; ++widerho){
if (figtures[temp][0])
System.out.print('-');
else
System.out.print(' ');
}
System.out.print(' ');
if (digits != num.length()-1)
System.out.print(' ');
break;
case 1:
if (figtures[temp][5])
sb.append('|');
else
sb.append(' ');
for (int widerho = 0; widerho < size ; ++widerho)
sb.append(' ');
if (figtures[temp][1])
sb.append('|');
else
sb.append(' ');
if (digits != num.length()-1)
sb.append(' ');

if (digits >= num.length()-1){
for (int w = 0;w < size ; ++w){
System.out.print(sb);
if (w != size -1)
System.out.println();
}
}

break;
case 2:
System.out.print(' ');
for (int widerho = 0; widerho < size ; ++widerho){
if (figtures[temp][6])
System.out.print('-');
else
System.out.print(' ');
}
System.out.print(' ');
if (digits != num.length()-1)
System.out.print(' ');
break;
case 3:
if (figtures[temp][4])
sb.append('|');
else
sb.append(' ');
for (int widerho = 0; widerho < size ; ++widerho)
sb.append(' ');
if (figtures[temp][2])
sb.append('|');
else
sb.append(' ');
if (digits != num.length()-1)
sb.append(' ');

if (digits >= num.length()-1){
for (int w = 0;w < size ; ++w){
System.out.print(sb);
if (w != size -1)
System.out.println();
}
}

break;
case 4:
System.out.print(' ');
for (int widerho = 0; widerho < size ; ++widerho){
if (figtures[temp][3])
System.out.print('-');
else
System.out.print(' ');
}
System.out.print(' ');
if (digits != num.length()-1)
System.out.print(' ');
break;
}

}
System.out.println();

}
st = new StringTokenizer(br.readLine());
size = Integer.parseInt(st.nextToken());
num = st.nextToken();
number = Integer.parseInt(num);
}
System.out.println();
return;
}

}


3.

import java.util.Scanner;

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: LCD Display
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=9&page=show_problem&problem=647
*
* @author Siegfried Ippisch
* @version 1.0, 24.06.2010
*
* Method : -
* Status : Accepted
* Runtime: 1.564
*/
public class LCDDisplay {

/*
* -a-
* | |
* f b
* | |
* -g-
* | |
* e c
* | |
* -d-
*/

private enum Digit{
zero(true,true,true,true,true,true,false),
one(false,true,true,false,false,false,false),
two(true,true,false,true,true,false,true),
three(true,true,true,true,false,false,true),
four(false,true,true,false,false,true,true),
fife(true,false,true,true,false,true,true),
six(true,false,true,true,true,true,true),
seven(true,true,true,false,false,false,false),
eight(true,true,true,true,true,true,true),
nine(true,true,true,true,false,true,true);

final boolean a,b,c,d,e,f,g;

Digit(boolean a, boolean b, boolean c, boolean d, boolean e, boolean f, boolean g){
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.e = e;
this.f = f;
this.g = g;
}

String getLine(int line, int size){
String s = "";

if(line==0 && a || line==size+1 && g || line==2*size+2 && d){
s += " ";
for(int i=0; i<size; i++)
s+="-";
s += " ";
return s;
}

if(0 < line && line < size+1){
s += f ? "|": " ";
for(int i=0; i<size; i++)
s += " ";
s += b ? "|": " ";
return s;
}
if(size+1 < line && line < 2*size+2){
s += e ? "|": " ";
for(int i=0; i<size; i++)
s += " ";
s += c ? "|": " ";
return s;
}

for(int i=0; i<size+2; i++)
s += " ";

return s;
}

}

private static void printDigits(int number, int size){
char[] chars = (""+number).toCharArray();
Digit[] digits = new Digit[chars.length];

for(int i=0; i<chars.length; i++)
switch(chars[i]){
case '0': digits[i] = Digit.zero; break;
case '1': digits[i] = Digit.one; break;
case '2': digits[i] = Digit.two; break;
case '3': digits[i] = Digit.three; break;
case '4': digits[i] = Digit.four; break;
case '5': digits[i] = Digit.fife; break;
case '6': digits[i] = Digit.six; break;
case '7': digits[i] = Digit.seven; break;
case '8': digits[i] = Digit.eight; break;
case '9': digits[i] = Digit.nine; break;
}

for(int i=0; i<2*size+3; i++){
String s = "";
for(Digit d: digits)
s += d.getLine(i, size) + " ";
s = s.substring(0, s.length()-1);
System.out.println(s);
}
}

public static void main(String[] args){
Scanner in = new Scanner(System.in);

int size = in.nextInt();
int number = in.nextInt();

while(size > 0 || number > 0){
printDigits(number, size);
System.out.println();

size = in.nextInt();
number = in.nextInt();
}

}

}

4. Martin Lambeck

package acm_706_lcd_display;

import java.util.*;

public class Main
{
static StringBuilder str = new StringBuilder(1000);


final static boolean[][] style = new boolean[][] {
{ true, true, true, false, true, true, true },
{ false, false, true, false, false, true, false },
{ true, false, true, true, true, false, true },
{ true, false, true, true, false, true, true },
{ false, true, true, true, false, true, false },
{ true, true, false, true, false, true, true },
{ true, true, false, true, true, true, true },
{ true, false, true, false, false, true, false },
{ true, true, true, true, true, true, true },
{ true, true, true, true, false, true, true } };

public static void main(String... args)
{

Scanner input = new Scanner(System.in);

while (input.hasNextInt())
{
ArrayList<Integer> nums = new ArrayList<Integer>(10);

int size = input.nextInt();

if (size == 0)
break;

int n = input.nextInt();

if (n == 0)
nums.add(0);

while (n > 0)
{
int mod = n % 10;
n = n / 10;

nums.add(0, mod);
}

str.delete(0, str.length());

doLine(size, nums);

str.append("\n");

System.out.print(str);
}
}

static void doLine(int size, List<Integer> nums)
{


boolean[][] layout = new boolean[nums.size()][7];

for (int i = 0; i < nums.size(); i++)
{
layout[i] = style[nums.get(i)];
}

show1(layout, size, 0);

show2(layout, size, 1, 2);

show1(layout, size, 3);

show2(layout, size, 4, 5);

show1(layout, size, 6);
}

static void show1(boolean[][] layout, int size, int segment)
{
for (int i = 0; i < layout.length; i++)
{
if (i > 0)
str.append(' ');

print(" ", " ", ((layout[i][segment]) ? "-" : " "), size);
}

str.append('\n');
}

static void show2(boolean[][] layout, int size, int seg1, int seg2)
{
for (int h = 0; h < size; h++)
{

for (int i = 0; i < layout.length; i++)
{
if (i > 0)
str.append(' ');

print((layout[i][seg1] ? "|" : " "), (layout[i][seg2] ? "|"
: " "), " ", size);
}

str.append('\n');
}
}

static void print(String head, String tail, String chr, int times)
{
str.append(head);

for (int i = 0; i < times; i++)
{
str.append(chr);
}

str.append(tail);
}

}