Transcription of an impression in an arrangement

0

I have the following code, and it asks me to modify it so that it prints it to be inserted in a matrix (two-dimensional array), how could it do it?

static int siguiente(int nn, int tope) {
    if (nn == tope) {
        return 0;
    } else {
        return nn + 1;
    }
}

public static void main(String[] args)  {
    int n = 5;
    int num = 0;
    for (int i = 0; i <= n; i++) {
        for (int k = 0; k <= n; k++) {
            System.out.println(num);
            if (k != n) {
                num = siguiente(num, n);
            }
        }
    }
    System.out.println("\n");
}

}

    
asked by EduardoGnR 09.03.2018 в 18:07
source

1 answer

0

Assuming you already have your matrix loaded and it is called matrix1.

declares an array assuming it is Integer (int). Note that n is the number of positions. that you should already know. This would go in the main

int [] arreglo = new int[n]; 

for(int i = 0; i<=n; i++){
     for(int j = 0; i<=j; j++){
        int cont = 0;


arreglo [cont] = matriz1[i][j];
cont++;

}

}

I hope it serves you something

    
answered by 09.03.2018 / 18:37
source