Help with making a random sequence of numbers 1-26
Author |
Message |
hersheychocolates
|
Posted: Mon Jan 18, 2010 5:59 pm Post subject: Help with making a random sequence of numbers 1-26 |
|
|
hey everyone
So here is a code that will put 26 numbers (all ranging from 1-26)
var i:int
var number : array 1 .. 26 of int
for counter1: 1..26
randint (i,1,26)
put i
end for
now what i was wondering is how we can make the program put 26 numbers, each ranging from 1-26 but not repeat a number that it has already previously generated! in other words, how can i make it so that it puts 1-26 in a random sequence?
thanks alot in advance! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Turing_Gamer
|
Posted: Mon Jan 18, 2010 6:13 pm Post subject: Re: Help with making a random sequence of numbers 1-26 |
|
|
I would do this
Turing: | for i : 1 .. 26
loop
num (i) := Rand.Int (1, 26)
for j: 1 .. i - 1
check := num (k) = num (i)
end for
exit when check = false
check := false % Reset if failed
end loop
end for |
|
|
|
|
|
|
hersheychocolates
|
Posted: Mon Jan 18, 2010 6:36 pm Post subject: RE:Help with making a random sequence of numbers 1-26 |
|
|
that doesnt work!!! it keeps saying you didnt declare num and check!! |
|
|
|
|
|
TheGuardian001
|
Posted: Mon Jan 18, 2010 6:53 pm Post subject: Re: Help with making a random sequence of numbers 1-26 |
|
|
they weren't giving you a working program, they were showing you the process so you can make your own... |
|
|
|
|
|
|
|