Guest User

Untitled

a guest
Mar 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. Random rnd = new Random();
  2.  
  3. int[][] array = new int[5][5];
  4. for (int row = 0; row < array.length; row++) {
  5. for (int col = 0; col < array[row].length; col++) {
  6.  
  7. array[row][col] = rnd.nextInt(6);
  8. }
  9. }
  10. for (int row = 0; row < array.length; row++) {
  11.  
  12. for (int col = 0; col < array[row].length; col++) {
  13.  
  14. if (col < 1) {
  15. System.out.print(row+" ");
  16. System.out.print(" " + array[row][col] + " ");
  17. } else {
  18.  
  19. System.out.print(" " + array[row][col] + " ");
  20. }
  21.  
  22. }
  23. System.out.println();
  24. }
  25.  
  26. 0 2 4 0 2 4
  27.  
  28. 1 1 2 0 2 2
  29.  
  30. 2 0 1 5 4 0
  31.  
  32. 3 4 2 1 4 1
  33.  
  34. 4 2 4 3 1 3
  35.  
  36. 0 1 2 3 4
  37. 0 2 4 0 2 4
  38. 1 1 2 0 2 2
  39. 2 0 1 5 4 0
  40. 3 4 2 1 4 1
  41. 4 2 4 3 1 3
Add Comment
Please, Sign In to add comment