Problem Description
Digital clock use 4 digits to express time, each digit is described by 3*3 characters (including”|”,”_”and” “).now given the current time, please tell us how can it be expressed by the digital clock.
Input
There are several test cases.
Each case contains 4 integers in a line, separated by space.
Proceed to the end of file.
Output
For each test case, output the time expressed by the digital clock such as Sample Output.
Sample Input
1 2 5 6 2 3 4 2
Sample Output
_ _ _ | _||_ |_ ||_ _||_| _ _ _ _| _||_| _| |_ _| ||_
Hint
Source
没有想出来简单的办法
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner cin = new Scanner(System.in);
int []a = new int[100];
int i ;
while(cin.hasNext())
{
for(i = 0;i<4;i++)
a[i] = cin.nextInt();
//Print 1st line
for(i = 0;i<4;i++)
{
switch(a[i])
{
case 0:System.out.print(" _ ");break;//
case 1:System.out.print(" ");break;//
case 2:System.out.print(" _ ");break;//
case 3:System.out.print(" _ ");break;//
case 4:System.out.print(" ");break;//
case 5:System.out.print(" _ ");break;//
case 6:System.out.print(" _ ");break;//
case 7:System.out.print(" _ ");break;//
case 8:System.out.print(" _ ");break;//
case 9:System.out.print(" _ ");break;//
}
}
System.out.println();
//Print 2 Line
for(i = 0;i<4;i++)
{
switch(a[i])
{
case 0:System.out.print("| |");break;//
case 1:System.out.print(" |");break;//
case 2:System.out.print(" _|");break;//
case 3:System.out.print(" _|");break;//
case 4:System.out.print("|_|");break;//
case 5:System.out.print("|_ ");break;//
case 6:System.out.print("|_ ");break;//
case 7:System.out.print(" |");break;//
case 8:System.out.print("|_|");break;//
case 9:System.out.print("|_|");break;//
}
}
System.out.println();
//Print 3Line
for(i = 0;i<4;i++)
{
switch(a[i])
{
case 0:System.out.print("|_|");break;//
case 1:System.out.print(" |");break;//
case 2:System.out.print("|_ ");break;//
case 3:System.out.print(" _|");break;//
case 4:System.out.print(" |");break;//
case 5:System.out.print(" _|");break;//
case 6:System.out.print("|_|");break;//
case 7:System.out.print(" |");break;//
case 8:System.out.print("|_|");break;//
case 9:System.out.print(" _|");break;//
}
}
System.out.println();
}
cin.close();
}
}