random number generator

Discussion in 'C++' started by iandigges@gmail.com, Apr 25, 2007.

  1. Guest

    I need a random number generator to produce a 0 or 1 that I can feed
    into a multidimensional array. Any hints?

    ~ Ian
     
    , Apr 25, 2007
    #1
    1. Advertising

  2. wrote:
    > I need a random number generator to produce a 0 or 1 that I can feed
    > into a multidimensional array. Any hints?


    int rand_bit()
    {
    return rand() > RAND_MAX / 2;
    }

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Apr 25, 2007
    #2
    1. Advertising

  3. Zeppe Guest

    wrote:
    > I need a random number generator to produce a 0 or 1 that I can feed
    > into a multidimensional array. Any hints?
    >


    use the rand() of the standard library.

    Regards,

    Zeppe
     
    Zeppe, Apr 25, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kingsley Oteng

    Random Number Generator??

    Kingsley Oteng, Apr 27, 2004, in forum: VHDL
    Replies:
    11
    Views:
    52,749
    rahul.iyer
    Aug 9, 2010
  2. tshad

    Random number/letter generator

    tshad, May 5, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    9,590
    tshad
    May 6, 2005
  3. Wally
    Replies:
    1
    Views:
    2,824
    pvdg42
    Mar 20, 2006
  4. globalrev
    Replies:
    4
    Views:
    797
    Gabriel Genellina
    Apr 20, 2008
  5. VK
    Replies:
    15
    Views:
    1,286
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page