Computer Science Canada

how do i write a pseudocode for the following?

Author:  kid105 [ 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

Author:  Carey [ 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


: