Raised This Month: $ Target: $400
 0% 

four unequal random number


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
c2d22
Junior Member
Join Date: Feb 2013
Location: Albania
Old 05-20-2014 , 12:27   four unequal random number
Reply With Quote #1

how to generate four unequal random number in a array. , Something with four loops will do it , maybe some other way exist , please tell me.
c2d22 is offline
OnePL
BANNED
Join Date: May 2012
Location: GB
Old 05-20-2014 , 13:07   Re: four unequal random number
Reply With Quote #2

random[sizeof(array)] ?
OnePL is offline
Send a message via ICQ to OnePL Send a message via AIM to OnePL Send a message via Yahoo to OnePL Send a message via Skype™ to OnePL
c2d22
Junior Member
Join Date: Feb 2013
Location: Albania
Old 05-20-2014 , 13:09   Re: four unequal random number
Reply With Quote #3


i meant , i want to create 4 random num which are unequal to each other..

PHP Code:
new random[4]
random[0] =  random_num(0,10)
random[1] =  random_num(0,10)
random[2] =  random_num(0,10)
random[3] =  random_num(0,10)


// and i want all these number to be unequal , any way without looping? example please 
c2d22 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 05-20-2014 , 13:11   Re: four unequal random number
Reply With Quote #4

The only way to make sure they are not the same is to use a loop
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
c2d22
Junior Member
Join Date: Feb 2013
Location: Albania
Old 05-20-2014 , 14:03   Re: four unequal random number
Reply With Quote #5

Quote:
Originally Posted by YamiKaitou View Post
The only way to make sure they are not the same is to use a loop
Please give an example , i messed up something . i am unable to.
c2d22 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-20-2014 , 17:41   Re: four unequal random number
Reply With Quote #6

What is the range of these random numbers?
If you keep it 1-31 or 0-30 you can use a bitsum instead of looping through all previous values.
__________________
Black Rose is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode