reset password
Author Message
harry_520
Posts: 76
Posted 11:20 Jan 12, 2015 |

Just want to understand the problem. Why do we need to generate random numbers, and how do we use them?

Last edited by harry_520 at 11:21 Jan 12, 2015.
303496263
Posts: 68
Posted 13:13 Jan 12, 2015 |

It says that the the first guy hits his target with 1/3 probability, so you should generate a random number in the range of [1-3]. Let's say when you get number 1,this guy hits his target otherwise(2 or 3) he misses. The chance of getting 1 out of rand() % 3 + 1 is 1/3. And this is how you simulate a shot.

 

harry_520
Posts: 76
Posted 15:04 Jan 12, 2015 |

Now I get it. Thanks for the clarification.