I'm really confused about how to do this problem, mathematically, and I would appreciate some help. The instructions are as follows:
"Similar to halfFilledRectangle with a frame, but inside the proportion of fill_char to space is ratio. Ratio is a float from 0 (no fill), to 1 (full fill). Use rand() to randomly fill the rectangle and be able to handle any value between 0 and 1 inclusive. Give a warning and exit if the given ratio is <0 or > 1. Assume srand will be called in main."
And the prototype and output for this function are:
void partialFilledRectangle(int width, int height, char fill_char, float ratio);
Which shape should I draw?7
What is Fill Character? &
Width?10
Height?8
Ratio?0.1
&&&&&&&&&&
& &
& & &
& &
& & &
& &
& &
&&&&&&&&&&
Currently I have this code, which creates a square frame that is half filled. I'm very confused about how to modify it; could I please have some help?
Once you have identified the cells to shade, for each cell, you need to generate a random number which is used to determine if you shade that cell or not.
If there's 1% chance of filling it, you could generate a number in the range 0-99 and only fill it when you get 0 for example.