Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Number Problems
#1
Hey, i have the Uniform and str.Random files but i cannot use them for what im trying to do, i need to be able to enter a number and it generate a number from 1 to w/e number i typed in.

Is this possible? maybe someone can help me out.

Thanks. QM_Expert
#2

Here are a couple examples.



This generates 1 random number.
Macro ( Uniform_Example )
Code:
Copy      Help
int random num
num=5;;edit your number here
random=Uniform(1 num)
out random


and

Macro ( Uniform_Example_Pi )
Code:
Copy      Help
int repeats count num
num=5
repeats=Uniform(1 num)
out "Random repeats = %i" repeats
rep repeats+1
,out count
,count+1

This will generate numbers counting up to the random number.

ie: Random number chosen is 6; counts 0 1 2 3 4 5 6.
Taking on Quick Macros one day at a time
#3
thanks bro the first one did the job perfectly!
#4
How do I get it to count 65 numbers, all random 65 times, but not repeating itself, like not have the same number show up twice from 1 to 65

Function Uniform_Example
Code:
Copy      Help
rep 65
,int random num
,num=65;;edit your number here
,random=RandomInt(1 num)
,out random

Any help?
#5
Macro
Code:
Copy      Help
ARRAY(int) a
a.create(65)
for _i 0 65
,a[_i] = _i + 1
int random
for _i 65 0 -1
,random = RandomInt(1 _i)
,out a[(random-1)]
,a.remove((random-1))


Forum Jump:


Users browsing this thread: 1 Guest(s)