Hi guys,
I have a question regarding iteration.
My assignment program deals with flipping a coin 500, 1000, 2000, 4000 times and recording the longest streak overall of the same outcome and the longest streak from the first flip.
For example, for n = 10 flips, H H T H T H H H H H...the longest streak would be 5 (5 heads) and the longest streak from the first flip would be 2 heads.
I've done that part of the program by setting up a random generator and a counter to calculate the longest streaks..
The question then asks me to repeat/iterate the program 1000 times and calculate the average of the streaks combined. I am not sure which function I would use to simulate it again and again:
Example: I flip the coin 500 times, the longest streak is 8. I flip the coin 500 times again.. the longest streak is 10. The average is 9. I need to do that 1000 times and calculate the average.
What function would I have to use for that?
http://www.cplusplus.com/reference/iterator/ I read through this reference but I am not sure if that's the way to go about it.