Witam
Mój problem polega na tym, że nie mogę zlokalizować błędu w kodzie, konkretnie chodzi o linijkę:
...
Sum(matrix, x+1, y, path+'1', sum, seq);
...
i błąd:
project1.lpr(43,8) Error: Illegal expression
project1.lpr(43,8) Fatal: Syntax error, ";" expected but "(" found
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes
{ you can add units after this };
{$R *.res}
type Ttab = array[0..10,0..10] of integer;
Tpath = array[0..22] of boolean;
var array_:Ttab;
m,n:integer;
winnerPath,winnerSequence:string;
winnerSum:integer=1000000;
const width=10; height=10; min=0; max=100;
procedure Sum(matrix:Ttab; x:integer; y:integer; path:string; sum:integer; seq:string);
var s:string;
begin
if (x>=width) OR (sum>winnerSum) OR (y<0) then break;
sum:=sum+matrix[x,y];
Str(matrix[x,y], s);
seq:=seq+s+ '+' ;
if (x=width-1) AND (y=0) AND (sum<winnerSum) then
begin
winnerSum:=sum;
winnerPath:=path;
winnerSequence:=seq;
end;
Sum(matrix, x+1, y, path+'1', sum, seq);
Sum(matrix, x, y-1, path+'0', sum, seq);
end;
begin
Randomize;
for m:=0 to 10 do
for n:=0 to 10 do array_[m,n]:=random(max);
Sum(array_,0, height-1, '', 0,'');
Writeln(winnerPath);
Writeln(winnerSum);
Writeln(winnerSequence);
end.