Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A new random generator
#1
Well, I need to come up with another random number generator. Here's the one I have.
Code:
CLS
INPUT "How many random numbers would you like to generate"; X
DIM A(X) AS INTEGER
FOR C = 1 TO X
A(C) = C
NEXT C
RANDOMIZE TIMER
FOR SWITCH = 1 TO 10
FOR C = 1 to X
B = INT(X * RND (1) + 1)
SWAP A(C), A(B)
NEXT C
NEXT SWITCH
FOR C = 1 TO X
PRINT A(C)
NEXT C
PRINT
OPEN "rnd.csv" FOR OUTPUT AS #1' This just makes it so you can put it in a spreadsheet and test it for no repeats"
FOR D = 1 TO X
PRINT #1, A(D)
NEXT D
CLOSE #1
but I need one that takes two arrays and you leave one unpopulated for now but with the other you generate a random number lets say five you assign that to position one in array A and in array B you go over to the fifth position and change the zero there to a one, then you generate a seven and you assign that to position two in array A and in array B you change the zero in the seventh position to a one and so on, and if you generate a random number in Array A that has already come up and its position in array b is assigned a one instead of a zero you erase that number from array A and reassign it with a new number. i need this one so i can compare the two to see which one  is more random. I got the other one pretty easily but  I don't quite know how to start this one
Reply
#2
(02-21-2008, 01:09 AM)Smurfy link Wrote:I don't quite know how to start this one
Code:
CLS
INPUT "How many random numbers would you like to generate"; X
DIM A(X) AS INTEGER
DIM B(X) AS INTEGER
FOR C = 1 TO X
  N = 1 + INT(RND * X)
  PRINT N
NEXT C

Then replace PRINT N to code which does what you said.

Mac
Reply
#3
Thank you, I'll see where that takes me.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)