[Lazarus] Valladolid Programming Contest simple test fails at compile?

Mehmet Erol Sanliturk sanliturk at ttmail.com
Thu Mar 26 23:47:45 CET 2009


On Thursday 26 March 2009 05:16:32 pm Thierry Coq wrote:
> 
>
>  >> TEST PROGRAM
>
> program Test1;
>
> var
>   i, j : integer; //input data
>   k, l : integer; //interval
>   m    : integer; //index
>   maxCycles : integer; //max number of cycles for the interval
>   Cycles: integer;
>
> // This function computes the number of cycles for the 3N+1 algorithm.
> function FindCycles(const value: integer):integer;
> begin
>   result := 1;
>   if value > 1 then
>   begin
>     if (value mod 2) > 0 then
>       result := 1+FindCycles(3*value+1)
>     else
>       result := 1+FindCycles(value div 2);
>   end;
> end;
>
> // main program
> begin
>   repeat
>     // get the input interval
>     readln(i,j);
>     k := i;
>     l := j;
>     if j<i then
>     begin
>       k := j;
>       l := i;
>     end;
>
>     //iterating over each element
>     maxCycles := 0;
>     for m := k to l do
>     begin
>       Cycles := FindCycles( m);
>       if Cycles > maxCycles then
>         maxCycles := Cycles;
>     end;
>
>     //write the results
>     writeln(i,' ',j,' ', maxCycles);
>
>   until eof;
> end.
>
> << END OF TEST PROGRAM
> _______________________________________________
> 


At until eof , there should be a file variable name as eof ( FN ) 
where FN may be

var FN : Text ;
or
var FN : File ... ;

Thank you very much .

Mehmet Erol Sanliturk










More information about the Lazarus mailing list