import java.util.Random;

class Main {

    public static void main(String[] args) {
        int tama = 5;
        String[][] arreglo2D = llenarMatriz(tama);
        equiz(tama, arreglo2D);
    }

    public static String[][] llenarMatriz(int x) {
        Random aleatorio = new Random(System.currentTimeMillis());
        String[][] matriz = new String[x][x];

        for (int fila = 0; fila < x; fila++) {
            for (int colu = 0; colu < x; colu++) {
                int num = aleatorio.nextInt(100); // genera números entre 0 y 99
                matriz[fila][colu] = String.valueOf(num);
            }
        }

        return matriz;
    }

    public static void equiz(int x, String arreglo2D[][]) {
        String jjoo = "";
        int otraV = x - 1;

        for (int fila = 0; fila < x; fila++) {
            for (int colu = 0; colu < x; colu++) {
                if (fila == colu || otraV == colu) {
                    jjoo = jjoo + " . " + "----";
                    if (otraV == colu) {
                        otraV--;
                    }
                } else {
                    jjoo = jjoo + " . " + arreglo2D[fila][colu];
                }
            }
            jjoo = jjoo + "\n";
        }

        System.out.println(jjoo);
    }
}




Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: