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

Username:   Password: 
 RegisterRegister   
 I need help on making this code smaller
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
blackwhite




PostPosted: Tue Jul 13, 2004 3:57 pm   Post subject: I need help on making this code smaller

code:
for x : 1 .. value (1)
    ticketid (x) := username (1)
end for

for x : value (1) .. value (2)
    ticketid (x) := username (2)
end for

for x : value (2) .. value (3)
    ticketid (x) := username (3)
end for

for x : value (3) .. value (4)
    ticketid (x) := username (4)
end for


I'm using this to make a random raffle draw for myself, but obviously this will only work if there are exactly 4 people. I would have to manually add code for it to work for more, and so I need it to use the amount of people (variable name "memnum").

In this code, I'm basically assigning each member to the ticket number they bought, so i can use a random number and find the ticketholder.
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Tue Jul 13, 2004 7:16 pm   Post subject: (No subject)

code:
value (0) := 1

for i : 1 .. 4
    for x : value (i - 1) .. value (i)
        ticketid (x) := username (i)
    end for
end for


make sure when you declare value, it is an array with lower bound 0.
blackwhite




PostPosted: Wed Jul 14, 2004 11:38 am   Post subject: (No subject)

thanks a lot. i tried something like that, but it didn't work for some reason, and it got confusing with all my variables, so i just restarted.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: