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

Username:   Password: 
 RegisterRegister   
 help with randomize
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
m4rk




PostPosted: Tue Feb 18, 2003 1:38 am   Post subject: help with randomize

i'm sorta new to turing, i need help with randomize words
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Feb 18, 2003 8:19 am   Post subject: (No subject)

there're two ways of getting a random number... ether rand() which returns a random float point number between 0 and 1 or randint() with returns a random integer in the range your specify (which is basically a modified rand anyway)

To get a random word, you can store your words in an array and use random integer to access your array.

such as put word(Rand.Int(1,10)) or if you don't know arrays, you can set up few if statments (which is not as good).

code:

randint(x,1,10)
if x = 1 then
put "word 1"
elsif x = 2 then
put "word 2"
...
elsif x = 10 then
put "word 10"
end if
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: