{ NXN.PAS Copyright (c) Jan Benkovic } { Napiste progarm, ktory vyplni celociselne dvojrozmerne pole } { rozmeru NxN postupne celymi cislami od 1 do NxN po vedlajsich } { uhloprieckach zhora dolu. } { } { Datum:12.04.2002 http://www.trsek.com } uses crt; const N = 5; {Max. 180} var pole:array[1..N,1..N] of word; X,Y : longint; pom : longint; pom_X : longint; pom_Y : longint; Xt : byte; begin clrscr; for x:=1 to N do pole[N,N]:=0; X:=0; Y:=0; pom:=0; pom_X:=1; pom_Y:=0; Xt:=0; pole[1,1]:=1; for Y:= 1 to N do begin inc(pom_X); for X:= 2 to N do begin if pom+pom_Y=N-1 then inc(Xt); if Xt=0 then inc(pom); if Xt=2 then dec(pom); pole[X,Y]:=pole[X-1,Y]+pom+pom_Y; end; Xt:=0; pom:=0; inc(pom_Y); if Y+1<=N then pole[1,Y+1]:=pole[1,Y]+pom_X; end; For Y:=1 to N do For X:=1 to N do begin Gotoxy(X*3,Y); Write(pole[X,Y]); end; readkey; end.