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

Username:   Password: 
 RegisterRegister   
 how do i write a pseudocode for the following?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kid105




PostPosted: Thu Jan 14, 2010 10:12 pm   Post subject: how do i write a pseudocode for the following?

write a program which generates one ticket for lotto 649. recall that each lotto 649 ticket consists of six different integers between 1 and 49. be carefull! your program must ensure that the ticket does not contain duplicate numbers.

i always get low marks on my pseudocode's can someone get me started im really stuck i still have to write the program itself. providing me the first few lines would be helpfull. thnx
Sponsor
Sponsor
Sponsor
sponsor
Carey




PostPosted: Thu Jan 14, 2010 10:25 pm   Post subject: RE:how do i write a pseudocode for the following?

what you want to do is have an array to keep track of which numbers you have already picked, and a for loop to pick the six numbers. so it would be like:

code:

declare array of length 6, initilize to all impossible numbers like 0
for i : 1 ..6
   loop
      temp = Rand.Int(1, 49)
      check using for loop of the number is in the array already
      if it isnt, exit
   end loop
   add temp to the array in position i
end for

use a for loop to print the contents of the array to see the numbers
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: