public class Main {
public static void main(String[] args) {
double[][] matriz = new double[10][10];
generarMatriz(matriz);
visualizar(matriz);
}
private static void visualizar(double[][] matriz) {
System.out.println("Matriz aleatoria:");
for (double[] doubles : matriz) {
System.out.format("%.2f%n%.2f%n", doubles[0], doubles[1]);
}
}
private static void generarMatriz(double[][] matriz) {
for (int x = 0; x < matriz.length; x++) {
for (int y = 0; y < matriz[x].length; y++) {
matriz[x][y] = Math.random() * 20 - 10;
}
}
}
}
[/aux_code]
Matriz 10×10
con
No hay comentarios
[aux_code language=»javascript» theme=»tomorrow» title=»Matriz 10×10″ extra_classes=»»]