Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Random rnd = new Random();
- int[][] array = new int[5][5];
- for (int row = 0; row < array.length; row++) {
- for (int col = 0; col < array[row].length; col++) {
- array[row][col] = rnd.nextInt(6);
- }
- }
- for (int row = 0; row < array.length; row++) {
- for (int col = 0; col < array[row].length; col++) {
- if (col < 1) {
- System.out.print(row+" ");
- System.out.print(" " + array[row][col] + " ");
- } else {
- System.out.print(" " + array[row][col] + " ");
- }
- }
- System.out.println();
- }
- 0 2 4 0 2 4
- 1 1 2 0 2 2
- 2 0 1 5 4 0
- 3 4 2 1 4 1
- 4 2 4 3 1 3
- 0 1 2 3 4
- 0 2 4 0 2 4
- 1 1 2 0 2 2
- 2 0 1 5 4 0
- 3 4 2 1 4 1
- 4 2 4 3 1 3
Add Comment
Please, Sign In to add comment