-2
I need to create a function to draw within a matrix full of 0 with size n x n, four positions to modify the value only of these drawn positions.
-2
I need to create a function to draw within a matrix full of 0 with size n x n, four positions to modify the value only of these drawn positions.
0
Uses the class java.util. and then something like this:
void fillRandomPositions(int[][] arr, int n, int positions) {
Random rnd = new Random();
for(int i=0; i<positions; i++)
arr[rnd.nextInt(n)][rnd.nextInt(n)] = 1; // Inserir os valores aqui
}
Browser other questions tagged java matrix random
You are not signed in. Login or sign up in order to post.
What do you already have of this function ready? We can help you build your function based on what you have already done
– DiegoSantos