title: randomly generated probability game with loops and elimination
body: <p>Here is my assignment:</p>
  
  <hr>
  
  <p>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 argument once and for all, they agreed
  on a duel to the death. Aaron was a poor shot and only hit his 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 ex-
  pert marksman and never missed. A hit means a kill and the person hit drops out of the duel.
  To compensate for the inequities in their marksmanship skills, the three decided that they
  would re 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.</p>
  
  <p>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.
  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 subroutines and functions to complete the
  problem.</p>
  
  <p>Hint
  Let's say Aaron's chance of hitting a target is 1/3. You can simulate this probability by
  generating a random variable R between 1 and 99 inclusive. What is the probability that
  R is less than 33? It's 1/3. Do you see where this is leading? If R  33, then we can
  simulate Aaron hitting a target. If R > 33, then he misses. You can also generate a random
  variable between 0 and 1 and check if it is less than 0.33.</p>
  
  <hr>
  
  <p>here is the code i was finally able to work up after rewriting from scratch twice:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;ctime&gt;
  using namespace std;
  
  
  int main ()
  {
      int aaron=1, bob=1,charlie=1, a=0,b=0,c=0,counter=0;
      srand(time(0));
      a= rand() % 100;
      if (a&lt;=33)//if aaron kills charlie
      {
          charlie=0;
  
          b= rand() % 100; //bob choots at aaron
          if (b&lt;=50)  //if bob kills aaron
          {
              aaron=0;
              cout&lt;&lt;"error1"&lt;&lt;endl;
          }
          else if (b&gt;50)
          {
              while (b&gt;50) //if bob misses
              {
                  a= rand() % 100; //aaron shoots at bob
                  if (a&lt;=33)// if he kills bob
                  {
                      bob=0;
                      cout&lt;&lt;"error2"&lt;&lt;endl;
                  }
                  else //if he misses
                  {
                      b= rand() % 100;//bob shoots at aaron
  
                      if (b&lt;=50)//if he kills him
                      {
                          aaron=0;
                          cout&lt;&lt;"error3"&lt;&lt;endl;
                      }
                      else //if he misses then the loop continues
                      {
                          counter++;
                      }
                  }
              }
          }
      }
      else if (a&gt;33)//aaron misses
      {
          b= rand() % 100; //bob shoots at charlie
          if (b&lt;=50) //he kills charlie
          {
              charlie = 0;
              a= rand() % 100; //aaron shoots at bob
              if (a&lt;=33)//aaron kills bob
              {
                  bob=0;
                  cout&lt;&lt;"error4"&lt;&lt;endl;
              }
              else //if not
              {
                  b= rand() % 100;//bob shoots at aaron
                  if (b&lt;=50) // if he kills aaron
                  {
                      aaron=0;
                      cout&lt;&lt;"error5"&lt;&lt;endl;
                  }
                  else if (b&gt;50)
                  {
                      while (b&gt;50)//if not then begin loop
                      {
                          a= rand() % 100; //aaron shoots at bob
                          if (a&lt;=33) //if he kills him
                          {
                              bob=0;
                              cout&lt;&lt;"error6"&lt;&lt;endl;
                          }
                          else
                          {
                              b= rand() % 100;;   //if not bob shoots at aaron
                              if (b&lt;=50)// if he kills aaron
                              {
                                  aaron=0;
                                  cout&lt;&lt;"error7"&lt;&lt;endl;
                              }
                              else
                              {
                                  counter++; //if not loop around
                              }
                          }
  
                      }
                  }
              }
          }
  
          else //he misses so charlies kills bob
          {
              bob=0;
              a= rand() % 100; //aaron shoots at charlie
              if (a&lt;=33) //aaron kills charlie
              {
                  charlie=0;
                  cout&lt;&lt;"error8"&lt;&lt;endl;
              }
              else // or charlie kills aaron
              {
                  aaron=0;
                  cout&lt;&lt;"error9"&lt;&lt;endl;
              }
          }
  
  
          if (charlie==0 &amp;&amp; bob==0)
          {
              cout&lt;&lt;"Aaron wins."&lt;&lt;endl;
          }
          else if (aaron==0 &amp;&amp; bob==0)
          {
              cout&lt;&lt;"Charlie wins."&lt;&lt;endl;
          }
          else if (charlie==0 &amp;&amp; aaron==0)
          {
              cout&lt;&lt;"Bob wins."&lt;&lt;endl;
          }
      }
  
      return 0;
  }
  </code></pre>
  
  <p>I added in the cout line with the error# for when i compile the program to see where my errors are. </p>
  
  <p>the program runs hoever if i get the cout lines of error1,2,3 and 6 i do not get a cout with a named winner that should come with it. furthermore with those numbers i seem to sometimes get a double result (i.e. a result with that error and another one from a different part of the program) leading me to assume there is a problem with my loop(s). </p>
  
  <p>I opted to use a loop instead of a recursive function as it was outside the scope of the assignment.</p>
  
  <p>I would appreciate any review of my syntax and form as I am truly stumped. </p>