update tests
This commit is contained in:
46
java/reverse/ReverseEven.java
Normal file
46
java/reverse/ReverseEven.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package reverse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ReverseEven {
|
||||
public static void main(String[] args) throws IOException {
|
||||
FastScanner sc = new FastScanner();
|
||||
int[][] lines = new int[8][];
|
||||
int linesCount = 0;
|
||||
|
||||
while (sc.hasNextLine()) {
|
||||
int[] line = new int[8];
|
||||
int count = 0;
|
||||
|
||||
while (sc.hasNextInt()) {
|
||||
if (count >= line.length) {
|
||||
line = Arrays.copyOf(line, line.length * 2);
|
||||
}
|
||||
line[count++] = sc.nextInt();
|
||||
}
|
||||
sc.nextLine();
|
||||
|
||||
line = Arrays.copyOf(line, count);
|
||||
|
||||
if (linesCount >= lines.length) {
|
||||
lines = Arrays.copyOf(lines, lines.length * 2);
|
||||
}
|
||||
lines[linesCount++] = line;
|
||||
}
|
||||
|
||||
PrintWriter out = new PrintWriter(System.out);
|
||||
for (int i = linesCount - 1; i >= 0; i--) {
|
||||
int[] line = lines[i];
|
||||
for (int j = line.length - 1; j >= 0; j--) {
|
||||
if ((i + j) % 2 == 0) {
|
||||
if (j < line.length - 1) out.print(" ");
|
||||
out.print(line[j]);
|
||||
}
|
||||
}
|
||||
out.println();
|
||||
}
|
||||
out.flush();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user