-3

For example, there is an array like this ==> array[10][10]

I want to pick a random element of this array like array[5][7] and assign it to 0.

How can I do it?

Anatoly
  • 20,799
  • 3
  • 28
  • 42
Semih Gür
  • 17
  • 3

1 Answers1

1

Should be something like:

srand((unsigned) time());  // For different result every second
int x = rand() % 10;
int y = rand() % 10;
array[x][y] = 0;
stark
  • 12,615
  • 3
  • 33
  • 50