Advertisement

Random

Started by January 11, 2003 08:58 AM
9 comments, last by OSN 21 years, 10 months ago
Sorry, can i ask to this forum''s people how to use a random function to select any number from 1 to 10 again? (my post dissapeared)
The old thread for you, I think.

If you want to see some of your recent posts, hit the "profile" button (left-most of the bunch containing "profile", "register", "bookmarks"...). Click on "view your profile" to see recent posts/threads.

HTH.

[EDIT: Or you could also find one of your posts and hit the "profile" button there. Forgot about that!]

[edited by - Alimonster on January 11, 2003 10:10:31 AM]
Advertisement
quote: Original post by OSN
Sorry, can i ask to this forum''s people how to use a random function to select any number from 1 to 10 again?

(my post dissapeared)


thins will generate random numbers

int a;

a = rand () % 11;

THIS will generate numbers from 0 to 10 .. so you check if the number is you will add one

if (a == 0)
a++;



easy aint it ?
Metal Typhoon
quote: Original post by Metal Typhoon
...<a lot of things>...

int i = (rand() % (max - min + 1)) + min;


Update GameDev.net system time campaign: ''date ddmmHHMMYYYY''
Arguing on the internet is like running in the Special Olympics: Even if you win, you're still retarded.[How To Ask Questions|STL Programmer's Guide|Bjarne FAQ|C++ FAQ Lite|C++ Reference|MSDN]
shall i incude some file.h??????????
someone told me that file . the file is called something with "studio" or lib
shall i incude some file.h??????????
someone told me that file .
Advertisement
shall i incude some file.h??????????
someone told me that file .
shall i incude some file.h??????????
someone told me that file .
If I remember corecly, you need time.h

~-~-~-~-~-~-~-~-~
RPG D&D
rand() is in stdlib.h
as is srand().
time() is in time.h, which most people use to generate a seed for the randomiser.

-Mezz

This topic is closed to new replies.

Advertisement