Thread: random

  1. #1
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608

    random

    is the a code to say to randomly goto a line between 2 lines like 100 and 200 expect for 104 and 304 and a bunch of other specefic lines. is this possible
    Email: [email protected] || AIM: MisterSako || MSN: [email protected]

    -the shroom has spoken

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    look in the tutorial section of this site for random numbers, look on the web for random numbers, SEARCH THIS BOARD FOR RANDOM NUMBERS!!!

    This question has been asked a million and one times.

    if that's not enough information, go to google and search for "problem solving tutorials"

    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  3. #3
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Get a random number. From there, use the random number in a switch statement, and call different functions in each case.

  4. #4
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    what? how about this you might understnad it bette,r i need a code to say to give a number to a varible like it randomly chooses a number between 100 and 200 besides smoe certina numbers. then go to the line with that number life if it chose 132 it goes to linme 132. can someone make a sameple cpp file for doign this or asomething similar.
    Email: [email protected] || AIM: MisterSako || MSN: [email protected]

    -the shroom has spoken

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    63
    Here is a snippet of the code

    int ln;
    srand(time(0));
    ln = rand()%100+200;
    goto ln;

    I think thats right.

    Just try it, you never know.
    tudehopet uses Borland Compiler 5.5
    and Visual C++ 6.

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    > then go to the line with that number life

    please people, proofread your posts to make sure they make sense!

    do you mean execute some line of code? jump to a certain line in a file? we are not mind readers

  7. #7
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    i need a code to picka random number inbatween two numbers than give it to a varible. thats the best way i cant explain it
    Email: [email protected] || AIM: MisterSako || MSN: [email protected]

    -the shroom has spoken

  8. #8
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    This might satisfy your needs.

    Code:
    #include <stdlib.h>
    #include <iostream.h>
    #include <time.h>
    
    int function(int*,int,int);
    
    int main()
    {
        int variable=0;
        srand( (unsigned)time( NULL ) );
        variable = function(&variable,100,200);
        cout << variable;
        return 0;
    }
    
    int function(int* variable, int lower, int upper)
    {
         return (*variable = upper - (rand()%(upper-lower)+1) );
    }

  9. #9
    Unregistered
    Guest
    variable = function(&variable,100,200);

    sorry 'bout that, should've been

    function(&variable,100,200);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. random to int?
    By psyadam in forum C# Programming
    Replies: 7
    Last Post: 07-22-2008, 08:09 PM
  2. Lesson #3 - Math
    By oval in forum C# Programming
    Replies: 2
    Last Post: 04-27-2006, 08:16 AM
  3. Another brain block... Random Numbers
    By DanFraser in forum C# Programming
    Replies: 2
    Last Post: 01-23-2005, 05:51 PM
  4. How do I restart a random number sequence.
    By jeffski in forum C Programming
    Replies: 6
    Last Post: 05-29-2003, 02:40 PM
  5. Best way to generate a random double?
    By The V. in forum C Programming
    Replies: 3
    Last Post: 10-16-2001, 04:11 PM