program patratlatin;
var i, j, n: integer;
matrice : array [1..50,1..50] of integer; // intre 1 si 50 randuri , intre 1 si 50 coloane
begin
write('Introduceti numarul <=50 : ');
readln(n);
if n <= 50 then
begin
for i:=0 to n do
for j:=0 to n do
matrice[i][j]:= (((i+j+n) mod n) + 1);
for i:=0 to n do
begin
writeln('');
for j:=0 to n do
write(matrice[i,j]);
end;
readln;
end
else
writeln('Numarul introdus este > 50');
readln;
end.