-
Notifications
You must be signed in to change notification settings - Fork 15
/
display.java
146 lines (139 loc) · 4.25 KB
/
display.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// https://open.kattis.com/problems/display
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
public class display {
public static void main(String[] args) throws IOException {
BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter dc = new BufferedWriter(new OutputStreamWriter(System.out));
while (true) {
String line = sc.readLine();
if (line.equals("end"))
break;
char[][] time = new char[7][29];
int i = 0;
for (char[] r : time)
Arrays.fill(r, ' ');
for (char c : line.toCharArray()) {
if (c == ':')
i += 3;
else
i += 7;
time = add(time, c, i);
}
for (char[] r : time) {
for (char c : r)
dc.write(c);
dc.write("\n");
}
dc.write("\n\n");
}
dc.write("end\n");
sc.close();
dc.flush();
}
private static char[][] add(char[][] arr, char w, int i) {
i = i == 17 ? 14 : i - 7;
int c = i;
int r = 0;
if (w == '0') {
arr = hor(arr, r, c);
for (int x = 0; x < 2; x++) {
arr = lvert(arr, r, c);
arr = rvert(arr, r, c);
r += 3;
}
arr = hor(arr, r, c);
} else if (w == '1') {
for (int x = 0; x < 2; x++, r += 3)
arr = rvert(arr, r, c);
} else if (w == '2') {
arr = hor(arr, r, c);
arr = rvert(arr, r, c);
r += 3;
arr = hor(arr, r, c);
arr = lvert(arr, r, c);
r += 3;
arr = hor(arr, r, c);
} else if (w == '3') {
for (int x = 0; x < 2; x++) {
arr = hor(arr, r, c);
arr = rvert(arr, r, c);
r += 3;
}
arr = hor(arr, r, c);
} else if (w == '4') {
arr = lvert(arr, r, c);
arr = rvert(arr, r, c);
r += 3;
arr = hor(arr, r, c);
arr = rvert(arr, r, c);
} else if (w == '5') {
arr = hor(arr, r, c);
arr = lvert(arr, r, c);
r += 3;
arr = hor(arr, r, c);
arr = rvert(arr, r, c);
r += 3;
arr = hor(arr, r, c);
} else if (w == '6') {
arr = hor(arr, r, c);
arr = lvert(arr, r, c);
r += 3;
arr = hor(arr, r, c);
arr = lvert(arr, r, c);
arr = rvert(arr, r, c);
r += 3;
arr = hor(arr, r, c);
} else if (w == '7') {
arr = hor(arr, r, c);
for (int x = 0; x < 2; x++, r += 3)
arr = rvert(arr, r, c);
} else if (w == '8') {
for (int x = 0; x < 2; x++) {
arr = hor(arr, r, c);
arr = lvert(arr, r, c);
arr = rvert(arr, r, c);
r += 3;
}
arr = hor(arr, r, c);
} else if (w == '9') {
arr = hor(arr, r, c);
arr = lvert(arr, r, c);
arr = rvert(arr, r, c);
r += 3;
arr = hor(arr, r, c);
arr = rvert(arr, r, c);
r += 3;
arr = hor(arr, r, c);
} else if (w == ':') {
r = 2;
for (int x = 0; x < 2; x++, r += 2)
arr[r][c] = 'o';
}
return arr;
}
private static char[][] lvert(char[][] arr, int r, int c) {
arr[r++][c] = '+';
arr[r++][c] = '|';
arr[r++][c] = '|';
arr[r++][c] = '+';
return arr;
}
private static char[][] rvert(char[][] arr, int r, int c) {
c += 4;
arr[r++][c] = '+';
arr[r++][c] = '|';
arr[r++][c] = '|';
arr[r++][c] = '+';
return arr;
}
private static char[][] hor(char[][] arr, int r, int c) {
for (char a : "+---+".toCharArray())
arr[r][c++] = a;
return arr;
}
}