samedi 31 décembre 2016

generate a random matrix in java

So am trying to generate a matrix which has random numbers and then i want to display it

this is the generation code

for(int i=0; i<matrice.length; i++){
        for(int k=0; k<matrice[i].length; k++){
            int value= (int) (Math.random() * 100 + 0);
            matrice[i][k] = value ;
            }
    }

the disp code:

        for(int i = 0; i < matrice.length; i++){
        for(int j = 0; j < matrice.length; j++){
            System.out.print(matrice[i][j] + "  ");
        }
        System.out.println();
    }   

any help i don't get any results i think the problem is in the generation code !




Aucun commentaire:

Enregistrer un commentaire