In the land of Puzzlevania, Aaron, Bob, and Charlie had an argument over which one of them

was the greatest puzzle-solver of all time. To end the arugment once and for all, they agreed on a

duel to the death (this makes sense?). Aaron was a poor shot and only hit this target with a

probability of 1/3. Bob was a bit better and hit his target with a probability of 1/2. Charlie was an

expert marksman and never missed. A hit means a kill and the person hit drops out of the duel.

(Perhaps he could come back as a zombie.).

To compensate for the inequities in their marksmanship skills, the three decided that they would

fire in turns, starting with Aaron, followed by Bob, and then by Charlie. The cycle would repeat

until there was one man standing. That man would be remembered for all time as the Greatest

Puzzle-Solver of All Time.

An obvious and reasonable strategy is for each man to shoot at the most accurate shooter still

alive, on the grounds that this shooter is the deadliest and has the best chance of hitting back.

Task :

Write a program to simulate the duel using this strategy. Your program should use random

numbers and the probabilities given in the problem to determine whether a shooter hits his target.

You will likely want to create multiple functions to complete the problem. Once you can

simulate a duel, add a loop to your program that simulates 10,000 duels. Count the number of

times that each contestant wins and print the probability of winning for each contestant (e.g., for

Aaron your might output "Aaron won 3595/10000 duels or 35.95%).


You can start out with:

#include <iostream>

#include <cstdlib>

#include <ctime>

using namespace std;

int main() {

srand(time(0)); //Since we will be using rand()


Review how does random number generator works

Use boolean variable for each to keep track if they are alive

( 0 false or 1 true )

Beceriler: C++ Programlama

Daha fazlasını gör: rand c programming, problem of probability, probability programming, probability problem, cstdlib, c programming random number, c programming rand, c programming boolean, can 0 be a probability, boolean programming, argument programming, charlie c, simulation program, puzzle problem, kill random, fire simulation, puzzle generator, puzzle problem using, problem probability, puzzle random, write program puzzle problem, duel, puzzle problem program, program puzzle problem, end argument

İşveren Hakkında:
( 4 değerlendirme ) Cleveland, United States

Proje NO: #6548243



A proposal has not yet been provided

%selectedBids___i_period_sub_7% gün içinde 20%project_currencyDetails_sign_sub_9% %project_currencyDetails_code_sub_10%
(30 Değerlendirme)

Bu iş için 4 freelancer ortalamada $28 teklif veriyor


Dear sir, The problem is so wonderful to me. I can complete right now for you. Kind regards, Tin Tan

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% USD
(3 Değerlendirme)

I am a Mechatronics Engineering student with considerably expertise knowledge in the job you posted. Good at c,c++, java, python..Deadline meeting is also assured as I can promise you. Please about the payment we can a Daha Fazla

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% USD
(0 Değerlendirme)

Non hai ancora fornito una proposta

in %bids___i_period_sub_35% gün içinde55%project_currencyDetails_sign_sub_37% %project_currencyDetails_code_sub_38%
(0 Değerlendirme)