Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with making a random sequence of numbers 1-26
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
hersheychocolates




PostPosted: 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
Sponsor
sponsor
Turing_Gamer




PostPosted: 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




PostPosted: 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




PostPosted: 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...
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: