主题:[求助]排列组合
我编写了一个排列的的程序 编译通过 但运行时总退出
///////程序
program lv;
type
k2=array [1..4] of integer;
var
l:k2;
procedure qiu(var k:k2);
var
i,g,t:integer;
m:array [1..4] of boolean;
begin
for i:=1 to 4 do m[i]:=true;
for i:=1 to 4 do
for g:=1 to 4 do
if k[i]=g then
begin
m[i]:=false;
t:=t+1;
end;
for i:=1 to 4 do
begin
if m[i]=true then k[t]:=i;
if m[i]=true then qiu(k);
if t=4 then
begin
for g:=1 to 4 do
begin
write(k[g]);
k[g]:=0;
writeln
end;
end;
end;
end;
begin
qiu(l);
end.
请各为大虾指导
///////程序
program lv;
type
k2=array [1..4] of integer;
var
l:k2;
procedure qiu(var k:k2);
var
i,g,t:integer;
m:array [1..4] of boolean;
begin
for i:=1 to 4 do m[i]:=true;
for i:=1 to 4 do
for g:=1 to 4 do
if k[i]=g then
begin
m[i]:=false;
t:=t+1;
end;
for i:=1 to 4 do
begin
if m[i]=true then k[t]:=i;
if m[i]=true then qiu(k);
if t=4 then
begin
for g:=1 to 4 do
begin
write(k[g]);
k[g]:=0;
writeln
end;
end;
end;
end;
begin
qiu(l);
end.
请各为大虾指导