I am trying to randomly fill a 10x10 grid with 10 characters of H
, 5 char of ~
and 5 char of *
and the rest with (blank space).
I can't think of a way to limit the outcomes to my desired limit.
This is what I have so far.
cout <<"GRID: \n"<<"______________________________\n";
for (int i = 0; i < 10; i++){
for (int j = 0; j < 10; j++){
char contents[4] = {'~','H',' ','*'};
char arrBoard[i][j];
arrBoard[i][j] = contents[rand() % 4] ;
cout <<"| "<< arrBoard[i][j];
}
cout<<" "<<endl;
}