Thread: random number program

  1. #16
    Registered User
    Join Date
    Feb 2003
    Posts
    31
    I tried removing the ".h" from the iostream but then I get a whole bunch of errors. I didn't realize I left the random.h in there. thank you for pointing it out.

  2. #17
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    did you remember the "using namespace std;" part?
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  3. #18
    Registered User
    Join Date
    Feb 2003
    Posts
    31
    No I didn't remember that part. I will try that. I am sure it is obvious that I am new to this. Thanks for pointing it out

  4. #19
    Registered User
    Join Date
    Nov 2003
    Posts
    168
    Originally posted by LuckY

    but most simplified like this:
    Code:
    if (temp == 0)
      break;
    else {
      //...
    }
    I doubt that will support the readability of the script :\
    -Felix
    Rots Soft
    If the facts don't fit the theory, change the facts.
    Albert Einstein (1879 - 1955)

  5. #20
    Registered User
    Join Date
    Feb 2003
    Posts
    31
    Originally posted by major_small
    did you remember the "using namespace std;" part?
    I put that in but I am still getting errors. If I use it as #include <iostream.h> it works ok. I have no Idea what I am doing wrong. I still can't get it to actually give out random numbers, it keeps giving me the same numbers all the time.

  6. #21
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    you probably just have an old compiler... just keep the <iostream.h> then...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  7. #22
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Originally posted by Felix
    I doubt that will support the readability of the script :\
    I was merely trying to learn thatdude about how to block code, not how to write the most readable code, but thanks for your comment either way.

  8. #23
    Registered User
    Join Date
    Feb 2003
    Posts
    31
    Am I doing something wrong with the random function? It keeps generating the same bumbers all the time.

  9. #24
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Did you seed the random number generator? srand(time(NULL));

  10. #25
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    yes, you missed out your "randomize()" function in your program.

  11. #26
    Registered User
    Join Date
    Nov 2003
    Posts
    168
    Originally posted by LuckY
    I was merely trying to learn thatdude about how to block code, not how to write the most readable code, but thanks for your comment either way.
    Yeah i figured that out, it was merely to stop the other guy from making "errors" like that.
    -Felix
    Rots Soft
    If the facts don't fit the theory, change the facts.
    Albert Einstein (1879 - 1955)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. random number gen & looping probelm :?
    By FoxeySoulSLayer in forum C++ Programming
    Replies: 1
    Last Post: 04-10-2009, 05:44 PM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. Random number + guessing game trouble
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-08-2007, 03:33 AM
  4. Generating a random number?
    By Konspiracy in forum C++ Programming
    Replies: 5
    Last Post: 04-28-2007, 12:33 AM
  5. How do I restart a random number sequence.
    By jeffski in forum C Programming
    Replies: 6
    Last Post: 05-29-2003, 02:40 PM