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

Username:   Password: 
 RegisterRegister   
 Getting the last kink out of my program about running arrays
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Chimaera




PostPosted: Sun Feb 08, 2004 2:57 pm   Post subject: Getting the last kink out of my program about running arrays

My program should run but doesn't run on account of an error that I cannot assign a subscript to arrays >.> I don't get why it doesn't work and also the other 2 errors are due to the same array issue. It says missing time compression value. Please help me thanks!

code:
var num : int
var distance : int
var clubdist : int

get distance
get num
var arrayofclubs : 1 .. num of int
for i : 1 .. num
    get arrayofclubs(i)
end for
for i : 1 .. num
    clubdist := clubdist + arrayofclubs(i)
end for
if clubdist = distance then
    put "Roberta wins in ", num
else
    put "Roberta acknowledges defeat"
end if
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Sun Feb 08, 2004 3:09 pm   Post subject: (No subject)

Um thats not how you do an array, isn't it:
code:

var arrayofclubs : array 1 .. num of int

oh yea
code:

var clubdist : int :=0

or whatever, or else it has no value. and can't be used in:
code:

    clubdist := clubdist + arrayofclubs(i)
Chimaera




PostPosted: Sun Feb 08, 2004 3:35 pm   Post subject: (No subject)

Thanks for your help. It works now! yay
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: