ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

Why this program get Compilation error?
Posted by WuLF 18 Jan 2007 18:48
var a:array [1..50,1..50] of integer;
    min,max,i,n,j,k,l:longint;
    mas:array [1..10000] of integer;

Function Maxi(i:integer; j:integer):longint;
var as,q,w,e,r:longint;
begin
 as:=0;
 q:=0; w:=0; e:=0; r:=0;
 if j+1<=n then q:=a[i,j]+a[i,j+1];
 if j-1>0 then w:=a[i,j]+a[i,j-1];
 if i+1<=n then e:=a[i,j]+a[i+1,j];
 if i-1>0 then r:=a[i,j]+a[i-1,j];
 if q>w then as:=q else as:=w;
 if as<e then max:=e;
 if as<r then max:=r;
 maxi:=as;
end;

begin
 readln(n);
 max:=n*n;
 min:=1;
 for i:=1 to n*n do
 begin
  if i mod 2=1 then begin mas[i]:=min; inc(min); end else begin mas[i]:=max; dec(max); end;
 end;

 k:=1;

 for l:=1 to n do
 begin
  if l mod 2=1 then
  begin
   for i:=1 to n do
   begin
    a[l,i]:=mas[k]; inc(k);
   end;
  end
  else
  begin
   for i:=n downto 1 do
   begin
    a[l,i]:=mas[k]; inc(k);
   end;
  end;
 end;

 max:=0;

 for i:=1 to n do
 begin
  for j:=1 to n do
  begin
   k:=maxi(i,j);
   if k>max then max:=k;
  end;
 end;

 writeln(max);
 for i:=1 to n do
 begin
  for j:=1 to n do
  begin
   write(a[i,j],' ');
  end;
  writeln;
 end;

end.
Re: Why this program get Compilation error?
Posted by KIRILL(ArcSTU) 18 Jan 2007 20:09
as - reserved word(replace it:)
Re: Why this program get Compilation error?
Posted by WuLF 18 Jan 2007 20:25
Thanks.