Ayuda con ejercicio java Tablero Matriz
Publicado por MARJORIE YANEZ (9 intervenciones) el 29/06/2021 13:23:39
AYUDA COMO PUEDO HACER PARA QUE RELLENE MI MATRIZ DE FORMA ALEATORIA PERO POR PAREJAS COMO DOS 1 , DOS 2, DOS 3 ASI HASTA DOS 12 Y COMPLETE MI MATRIZ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class _10_Tablero {
public static void main(String[] args) {
// TODO Apéndice de método generado automáticamente
int[][] matriz = new int[6][4];
int cont = 0;
for (int i = 0; i < matriz.length; i++) {
for (int j = 0; j < matriz[i].length; j++) {
matriz[i][j] = (int) (Math.random() * 12 + 1);
}
}
for (int i = 0; i < matriz.length; i++) {
for (int j = 0; j < matriz[i].length; j++) {
System.out.print(matriz[i][j] + "\t");
}
System.out.println();
}
}
}
Valora esta pregunta


0