
-----------------------------------
Shadowsithe
Mon Nov 08, 2004 1:13 pm

Shuffly Ruffly
-----------------------------------
I'm trying to make a program that shuffles "cards." The variables values will change, however, when outputting they go in sequential order. Help please?

-----------------------------------
cool dude
Mon Nov 08, 2004 1:59 pm


-----------------------------------
show the code you have so far and we will help you.
it's kinda funny because i just made a program like that. some advice would be use functions. trust me its much easier using functions doing a program like that.

-----------------------------------
cool dude
Mon Nov 08, 2004 2:00 pm


-----------------------------------
k sorry i am checked your message on my schools computer and didn't see your code because our school computers don't allow that. sorry again

-----------------------------------
AsianSensation
Mon Nov 08, 2004 8:22 pm


-----------------------------------
k, there are some fundamental problems here:

proc swapola (var inta, intb : int)
    var intc : int
    intc := inta
    inta := intb
    intb := intc
end swapola

This proc changes the value of inta and intb, two variables you declared in the parameter of the procedure. Basicly, it doesn't do anything to affect the product you try to output.

I see what you are trying to do, except you kinda did it the hard way. I suggest something easier:

var cardtag : array 1 .. 52 of int := init (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
    42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52)

var temp, rand1, rand2 : int

for rep : 1 .. 100
    randint (rand1, 1, 52)
    randint (rand2, 1, 52)
    temp := cardtag (rand1)
    cardtag (rand1) := cardtag (rand2)
    cardtag (rand2) := temp
end for

for rep : 1 .. 52
    put cardtag (rep)
end for


Basicly, I just did a bubble sort and switched two cards.
