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

Username:   Password: 
 RegisterRegister   
 Errr im practising and got stuck
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Flikerator




PostPosted: Sat Mar 05, 2005 12:16 am   Post subject: Errr im practising and got stuck

Alright here it is;

code:

function moves (var a1, b1, c1, d1 : int) : int
    a1 := a (i)
    b1 := b (i)
    c1 := c (i)
    d1 := d (i)
end moves

It wont work because "i" hasnt been declared yet, and here it is;

code:

for i : 1 .. 5
    put "There are ", "moves from (", a (i), ",", b (i), " to (", c (i), ",", d (i), ")"
end for


Here is the entire thing;

code:
var a, b, c, d : array 1 .. 5 of string
var file : int

open : file, "Data32.txt", get

for i : 1 .. 5
    get : file, a (i)
    get : file, b (i)
    get : file, c (i)
    get : file, d (i)
end for

function moves (var a1, b1, c1, d1 : int) : int
    a1 := a (i)
    b1 := b (i)
    c1 := c (i)
    d1 := d (i)
end moves

for i : 1 .. 5
    put "There are ", "moves from (", a (i), ",", b (i), " to (", c (i), ",", d (i), ")"
end for



I just need to make the a1,b1,c1,d1 vars into those so I can make the calculation for later. This draws from a file so you cant really get the answers...
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sat Mar 05, 2005 7:54 am   Post subject: (No subject)

I don't get it. For one, your moves function doesn't return a value. And you're not calling your moves function anywhere. (Or do you do that later?)
Anyways, you've got two choices. Here they are:

code:

function moves (i : int, var a1, b1, c1, d1 : int) : int
    a1 := a (i)
    b1 := b (i)
    c1 := c (i)
    d1 := d (i)
    %you need a result something somewhere in here.  That, or make it a proc
end moves

%to call it:
for i : 1 .. 5
    moves (i, someVariable, someOtherVariable, anotherVariable, finallyTheLastVariable)
end for


or

code:

function moves (var a1, b1, c1, d1 : int) : int
    for i : 1 .. 5
        a1 := a (i)
        b1 := b (i)
        c1 := c (i)
        d1 := d (i)
    end for
    %again, make it result something, or make it a proc
end moves

%and to call it
moves (i, someVariable, someOtherVariable, anotherVariable, finallyTheLastVariable)

Hope that helps,
-Cervantes
Flikerator




PostPosted: Sat Mar 05, 2005 12:06 pm   Post subject: (No subject)

Well I couldn't do the calculation accuratly until I got those variables, but yes that works thank you again lolz.
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: