-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray_Simulation
More file actions
39 lines (31 loc) · 951 Bytes
/
Copy pathArray_Simulation
File metadata and controls
39 lines (31 loc) · 951 Bytes
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
package basicjava;
import java.util.Arrays;
public class ProblemSolving {
public static void main(String[] args) {
String result = convert("PAYPALISHIRING", 3);
System.out.println(result);
}
static public String convert(String s, int numRows) {
int sSize = s.length();
char[][] zigzag = new char[numRows][sSize / 2];
for (char[] row : zigzag) {
Arrays.fill(row, '0');
}
// for (int i = 0; i < sSize; i++) {
// for (int j = 0; j < 10; j++) {
//
// }
// }
for (int j = 0; j < numRows; j++) {
for (int i = 0; i < sSize / 2; i++) {
try {
System.out.print(zigzag[j][i]);
Thread.sleep(100);
} catch (Exception e) {
}
}
System.out.println("");
}
return "";
}
}