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

Username:   Password: 
 RegisterRegister   
 Shuffly Ruffly
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Shadowsithe




PostPosted: Mon Nov 08, 2004 1:13 pm   Post subject: 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?


shuffler.t
 Description:
Shuffler Source

Download
 Filename:  shuffler.t
 Filesize:  1011 Bytes
 Downloaded:  120 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
cool dude




PostPosted: Mon Nov 08, 2004 1:59 pm   Post subject: (No subject)

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




PostPosted: Mon Nov 08, 2004 2:00 pm   Post subject: (No subject)

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




PostPosted: Mon Nov 08, 2004 8:22 pm   Post subject: (No subject)

k, there are some fundamental problems here:

code:
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:

code:
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.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: