/ Vijos / 讨论 / 分享 /

菜鸟求救!!

P1143程序编译时出现以下错误:

Prog2070.pas(7,8) Error: Illegal assignment to for-loop variable "u"

Prog2070.pas(9,10) Error: Illegal assignment to for-loop variable "v"

Prog2070.pas(30,4) Fatal: Syntax error, ";" expected but "." found

Fatal: Compilation aborted

程序代码:

var a:array [1..20,1..20] of integer;b:array [1..20,1..20,1..3] of integer;sum,n,i,j:integer;

procedure work(x,y:integer);

var u,v,t,max:integer;sta:array [1..6] of integer;

begin

for u:=1 to 3 do if b[x-1,y,u]0 then begin inc(t); sta[t]:=b[x-1,y,u];

for v:=1 to 3 do if b[x,y-1,u]0 then begin inc(t); sta[t]:=b[x-1,y,u];

for u:=1 to 3 do begin

max:=1;

for v:=1 to t do begin

if sta[v]>sta[max] then max:=v;

if sta[max]=0 then break

else begin

b[x,y,u]:=sta[max]+a[x,y];

sta[max]:=0;

end;

end;

end;

end;

begin

readln(n);

for i:=1 to n do

for j:=1 to n do read(a);

b[1,1,1]:=a[1,1];

for i:=2 to n do b:=b+a;

for i:=2 to n do b[1,i,1]:=b[1,i-1,1]+a;

for i:=2 to n do

for j:=2 to n do work(i,j);

for i:=1 to 3 do if b[n,n,i]>0 then inc(sum,b[n,n,i]);

writeln(sum);

end.

自己怎么看都不知道是哪里错了……

1 条评论

  • @ 2009-04-26 09:18:07

    for u:=1 to 3 do if b[x-1,y,u]0 then begin inc(t); sta[t]:=b[x-1,y,u];

    for v:=1 to 3 do if b[x,y-1,u]0 then begin inc(t); sta[t]:=b[x-1,y,u];

    每句掉了一个end

  • 1