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

Username:   Password: 
 RegisterRegister   
 Generating Random Strings..
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
crimsonXess




PostPosted: Wed Oct 15, 2008 5:23 pm   Post subject: Generating Random Strings..

For my game i need to generate 3 random strings 'r' 't' 'y', and i don't have the slightest idea on how to go about it anyone got any answers?
Sponsor
Sponsor
Sponsor
sponsor
HellblazerX




PostPosted: Wed Oct 15, 2008 5:38 pm   Post subject: RE:Generating Random Strings..

Do you mean create random strings given those 3 letter? If that was the case, you could represent each letter by a number and use the Math.random function to randomize your strings.
crimsonXess




PostPosted: Wed Oct 15, 2008 7:22 pm   Post subject: Re: Generating Random Strings..

Do you mind giving me that info in more detail...im a total noob Neutral
The_Bean




PostPosted: Wed Oct 15, 2008 7:26 pm   Post subject: Re: Generating Random Strings..

Do you mean random letters in the strings:
string1 = "sdkfhj;ladfka"
string2 = "adnsjknarun"
string3 = "aksdncjkrn"

or do u mean a random order of the strings you already have:
str1,str2,str3
str2,str3,str1
str2,str1,str3
str3,str1,str2
...
Tony




PostPosted: Wed Oct 15, 2008 8:12 pm   Post subject: RE:Generating Random Strings..

I don't think it matters -- the process is the same (it's the same as one would generate a "random" number); the difference is in the alphabet of the target language.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
crimsonXess




PostPosted: Wed Oct 15, 2008 9:19 pm   Post subject: Re: Generating Random Strings..

Yes..what tony said, i know that but with the random int for character...
and i need it to be

string 1,string2,string3
string 2,string1,string3
etc...
that way thnz
Smile
andrew.




PostPosted: Sat Oct 18, 2008 12:04 am   Post subject: RE:Generating Random Strings..

Well you could use Rand.Int (or randint, I forgot which is better) and make it choose from 1 to 3. Use if statements so that 1 would be r or whatever, 2 would be whatever and so on. Then just put the letters that correspond with the numbers (what you used in the if statement). I hope I am making this clear.
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  [ 7 Posts ]
Jump to:   


Style:  
Search: