Flipping a coin!

This is a discussion on Flipping a coin! within the C++ Programming forums, part of the General Programming Boards category; Hello, Just a beginner! I've got a darts game between two players. I need to work out how many games ...

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    13

    Flipping a coin!

    Hello,


    Just a beginner! I've got a darts game between two players. I need to work out how many games player 1 wins and player 2 wins out of 1000 games if there is a coin flip and thereafter the loser starts.


    Code:
    if (p1 < p2) 
            wins = 1 ;
        else 
            wins = 0 ;

    This is my code for if p1 has less throws than p2 then they win. I just don't know how to make them flip for it!


    Thanks alot,


    Hannah
    Last edited by Valdo; 03-25-2012 at 10:13 AM.

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,438
    well its just a 0 / 1 random number genertion isnt it
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,031
    You can find out about random numbers by studying std::rand and std::srand.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. coin toss
    By ejd81882 in forum C Programming
    Replies: 3
    Last Post: 10-14-2008, 01:53 PM
  2. coin flipping
    By MiroMage in forum C Programming
    Replies: 5
    Last Post: 10-01-2008, 07:47 PM
  3. coin problem
    By et1wilson in forum C Programming
    Replies: 5
    Last Post: 07-14-2008, 06:19 AM
  4. Problems with a simple coin flipping program
    By Thileepan_Bala in forum C Programming
    Replies: 14
    Last Post: 01-18-2008, 08:33 PM
  5. Coin Toss
    By kazuakijp in forum C Programming
    Replies: 4
    Last Post: 08-31-2004, 10:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21