Chapter 10 Exercise Set 0: Chapter ReviewΒΆ
Rerun the
how_many
experiment from the Counting section with larger values fornum_values
and describe your results. Try callingsrand
seeded with the current time. Repeat this several times, documenting your results.Encapsulate the single pass histogram from the A histogram section in a function named
histogram
that takes a vector and a range of values in the vector (which was 0 through 9 in the example), and returns a histogram of the values in the vector.Open a file named
random_numbers.dat
containing several lines of random integers seperated by spaces, and read them into a vector namednumbers
. Then use the insertion sort algorithm presented in the Other member functions section to sort these numbers. Finally, open a file namedsorted_numbers.dat
for writing, and write out your sorted list of numbers to this file.