Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- import java.util.*;
- @SuppressWarnings("Duplicates")
- public class Test {
- public static void main(String[] args) {
- FastestScanner input = null;
- try {
- input = new FastestScanner(System.in);
- List<List<Integer>> matrix = new ArrayList<>();
- while (!input.endOfStream()) {
- input.readByte();
- ArrayList<Integer> row = new ArrayList<>();
- while (!input.endOfLine()) {
- Integer next = input.nextInt();
- if (next != null)
- row.add(next);
- }
- if (row.size() != 0)
- matrix.add(row);
- }
- for (List<Integer> matrixRow : matrix) {
- for (Integer matrixColumn : matrixRow) {
- System.out.print(matrixColumn + " ");
- }
- System.out.println();
- }
- } catch (IOException e) {
- System.out.println("I/O exceptions");
- } catch (NumberFormatException e) {
- System.out.println("Cant parse int!");
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- System.out.println("I/O exceptions");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement