Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.util.*;
  3.  
  4. @SuppressWarnings("Duplicates")
  5. public class Test {
  6. public static void main(String[] args) {
  7. FastestScanner input = null;
  8. try {
  9. input = new FastestScanner(System.in);
  10. List<List<Integer>> matrix = new ArrayList<>();
  11. while (!input.endOfStream()) {
  12. input.readByte();
  13. ArrayList<Integer> row = new ArrayList<>();
  14. while (!input.endOfLine()) {
  15. Integer next = input.nextInt();
  16. if (next != null)
  17. row.add(next);
  18. }
  19. if (row.size() != 0)
  20. matrix.add(row);
  21. }
  22. for (List<Integer> matrixRow : matrix) {
  23. for (Integer matrixColumn : matrixRow) {
  24. System.out.print(matrixColumn + " ");
  25. }
  26. System.out.println();
  27. }
  28. } catch (IOException e) {
  29. System.out.println("I/O exceptions");
  30. } catch (NumberFormatException e) {
  31. System.out.println("Cant parse int!");
  32. } finally {
  33. if (input != null) {
  34. try {
  35. input.close();
  36. } catch (IOException e) {
  37. System.out.println("I/O exceptions");
  38. }
  39. }
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement