[H-30]
Modify the previous program so that it prints
out a bar graph of stars in addition to printing out the values in each histogram
bin. Write the program so that the bars of the graph span the page for whatever
value of N is being used. To do this, look through the histogram for its maximum
value. Divide the maximum number of stars by this value to find the ratio of
stars to values. A sample output for N==500 is:
0 ( 50):***************************************** 1 ( 59):************************************************* 2 ( 42):*********************************** 3 ( 49):**************************************** 4 ( 41):********************************** 5 ( 53):******************************************** 6 ( 60):************************************************** 7 ( 47):*************************************** 8 ( 54):********************************************* 9 ( 45):*************************************
This program is too long to write as one big main()
. (My solution
is about 30 lines long, not counting comments and blank lines.) Make the histogram
array a global variable, and write three functions that use it: generate()
,
findMax()
, and plot()
. Write main()
using
these three functions.