Random Numbers and Removing only 1 item at a time

Discussion in 'C++' started by deanfamily, Dec 8, 2005.

  1. deanfamily

    deanfamily Guest

    I have a double-linked list. I need to insert RANDOM numbers into it. The
    rand() function doesn't put "random" number in the list, in the sense that
    every time you run the program it should produce new numbers. Also, I need
    to know if it is possible to remove just one of an item, instead of all that
    match the given criteria with the remove command. Any thoughts?
     
    deanfamily, Dec 8, 2005
    #1
    1. Advertising

  2. deanfamily

    Marcus Kwok Guest

    deanfamily <> wrote:
    > I have a double-linked list. I need to insert RANDOM numbers into it. The
    > rand() function doesn't put "random" number in the list, in the sense that
    > every time you run the program it should produce new numbers.


    Are you seeding the random number generator? Look up srand().

    --
    Marcus Kwok
     
    Marcus Kwok, Dec 8, 2005
    #2
    1. Advertising

  3. deanfamily

    deanfamily Guest

    "Marcus Kwok" <> wrote in message
    news:dnac11$p2i$...
    > deanfamily <> wrote:
    >> I have a double-linked list. I need to insert RANDOM numbers into it.
    >> The
    >> rand() function doesn't put "random" number in the list, in the sense
    >> that
    >> every time you run the program it should produce new numbers.

    >
    > Are you seeding the random number generator? Look up srand().
    >
    > --
    > Marcus Kwok


    I didn't know of that until you mentioned it, but I just implemented it in
    my code, and it works just fine. Thanks for the idea.
     
    deanfamily, Dec 8, 2005
    #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. globalrev
    Replies:
    4
    Views:
    822
    Gabriel Genellina
    Apr 20, 2008
  2. Alex Untitled
    Replies:
    11
    Views:
    686
    Giampiero Zanchi
    Nov 16, 2009
  3. PerlFAQ Server

    FAQ 4.10 Why aren't my random numbers random?

    PerlFAQ Server, Feb 12, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    234
    PerlFAQ Server
    Feb 12, 2011
  4. PerlFAQ Server

    FAQ 4.10 Why aren't my random numbers random?

    PerlFAQ Server, Apr 27, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    270
    PerlFAQ Server
    Apr 27, 2011
  5. VK
    Replies:
    15
    Views:
    1,335
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page