fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner scan = new Scanner(System.in);
  13.  
  14. List<int[]> temp = new ArrayList<>();
  15.  
  16. int[] couple = new int[2];
  17. int current = 0;
  18. while (scan.hasNextInt()) {
  19. if (current == 2) {
  20. temp.add(couple);
  21. current = 0;
  22. couple = new int[2];
  23. }
  24. couple[current] = scan.nextInt();
  25. current++;
  26. }
  27. if (current == 2) {
  28. temp.add(couple);
  29. }
  30. scan.close();
  31. System.out.println(temp.size());
  32. for (int[] a : temp) {
  33. System.out.println(a[0]+" "+a[1]);
  34. }
  35. }
  36. }
Success #stdin #stdout 0.13s 321088KB
stdin
4 6
2 3
4 8
9 5
stdout
4
4 6
2 3
4 8
9 5