I need help with a 2d array that's 80x20 and has 100 elements placed randomly in it, the other elements are blank spaces so it'll look like a starry sky.
I have a preliminary code figured out, but I need a mechanism that'll set 100 "*" elements randomly in the array. I was thinking maybe an if else statement would work, but am at a loss as to how that should be done.
If someone could point me in the right direction that would be magnificent!
const int rows = 80; // declares the amount of rows in the 2d array
const int cols = 20; // declares the amount of columns in the 2d array
int sky [rows][cols]; // declares the integers in the 2d array
unsigned seed = time(0);
int i ;
for(int r = 0; r < rows; r++)
for(int j = 0; j < cols; j++)
if(something that puts the 100 elements randomly in the array)
cout << " * ";
else // puts a blank space between the stars
cout << " ";