I need to create a function to sort within an array full of 0 with size n x n, four positions to modify the value of only those positions drawn.
I need to create a function to sort within an array full of 0 with size n x n, four positions to modify the value of only those positions drawn.
Use the java.util.Random class and then something of this genus:
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
}