Computer Science Canada Help with multiplication thing- you'll see |
Author: | - IzAk - [ Tue May 29, 2007 1:17 pm ] |
Post subject: | Help with multiplication thing- you'll see |
can somone mak the numbers on the x axis equal the numbers on the y axis.(through multiplication) kinda of like the game battleships layout. function CreateHorizontalV2 : array 1 .. 5 of int % (no parameters needed) var X : array 1 .. 5 of int var found : boolean X (1) := Rand.Int (2, 9) % pick any random for the first one for i : 2 .. 5 loop X (i) := Rand.Int (2, 9) % pick a random number found := false % assume it hasn't been used before for j : 1 .. i - 1 % check all previous numbers to see if a duplicate exists if X (i) = X (j) then found := true % bad - must try a new random exit end if end for exit when found = false end loop end for result X end CreateHorizontalV2 function CreateVerticalV2 : array 1 .. 5 of int % (no parameters needed) var X : array 1 .. 5 of int var found : boolean X (1) := Rand.Int (2, 9) % pick any random for the first one for i : 2 .. 5 loop X (i) := Rand.Int (2, 9) % pick a random number found := false % assume it hasn't been used before for j : 1 .. i - 1 % check all previous numbers to see if a duplicate exists if X (i) = X (j) then found := true % bad - must try a new random exit end if end for exit when found = false end loop end for result X end CreateVerticalV2 % MAIN var hN : array 1 .. 5 of int hN := CreateHorizontalV2 put " ".. for i : 1 .. 5 put hN (i) : 3 .. end for put "" var vN : array 1 .. 5 of int vN := CreateVerticalV2 for i : 1 .. 5 put vN (i) : 3 end for put "" |
Author: | rollerdude [ Thu May 31, 2007 9:50 am ] |
Post subject: | Re: Help with multiplication thing- you'll see |
first: being a programmer rank, yuo should know by now that when you post code, to use code tags second: i dont think i quite understand what ur trying to do... is it that you want it to look like: 2 7 4 9 8 5 4 3 6 9 instead of the other way around? why? unless you need to draw it the opposite way way then the comp remembers it the only thing i could suggest is to draw the x's in place of the y's and vice versa maybe if you clarify what ur trying to do, we can help more..er |
Author: | - IzAk - [ Mon Jun 04, 2007 11:03 am ] |
Post subject: | RE:Help with multiplication thing- you\'ll see |
ok sorry but this is what i want it to look like 5 3 6 7 ------------------- 4|20 12 24 28 | 9|45 27 54 63 | 2| and so on...... |
Author: | - IzAk - [ Mon Jun 04, 2007 11:05 am ] |
Post subject: | RE:Help with multiplication thing- you\'ll see |
sorry for the double post but i dont want it to print the answers in the run window i want to be able to put them in myself after the program has began to run.... |
Author: | rollerdude [ Mon Jun 04, 2007 11:38 am ] | ||
Post subject: | Re: Help with multiplication thing- you'll see | ||
like be able to put in the numbers that the table is going to multiply by?... well then, i'd put the numbers across the top in one array, and the ones on the sides in another... how to ask for them is another story, but to get it to multiply would be something like:
something aong those lines? |