const max=40;
type mat=array [1..max,1..max] of integer;
var a,b:mat;
i,j,det: integer;
procedure vivod(a:mat;n:integer);
var i,j:integer;
begin
for i:=1 to n do
begin
for j:=1 to n do
begin
write(a[i,j]:5);
end;
writeln;
end;
end;
procedure minor(a:mat;var b:mat; n,i,j:integer);
var k,l,s,t:integer;
begin
s:=0;
for k:=1 to n-1 do
begin
if (k=i) then s:=1;
t:=0;
for l:=1 to n-1 do
begin
if (l=j) then t:=1;
b[k,l]:=a[k+s,l+t];
end;
end;
end;
function opredilitel(a:mat;n:integer):integer;
var i,j,g:integer;
b:mat;
begin
det:=0;
g:=1;
i:=1;
j:=1;
if (n=1) then det:=a[i,j]
else for j:=1 to n do
begin
minor(a,b,n,1,j);
det:=det+g*a[1,j]*opredilitel(b,n-1);
g:=-g;
end;
opredilitel:=det;
end;
var n:integer;
begin
writeln('vvedite razmernost');
readln(n);
if (n>max)or(n<1) then writeln('oshibka')
else
begin
writeln('vvedite matricu');
for i:=1 to n do
for j:=1 to n do
begin
writeln('element a[',i,',',j,']');
readln(a[i,j]);
end;
writeln('---------');
vivod(a,n);
det:=opredilitel(a,n);
writeln('---------');
writeln('opredilitel=',det,'');
end;
end.