主题:排列
program ex_1;
const
m=10;
var
a:array[1..m] of char;
z:integer;
procedure swap(aa,bb:integer);
var
cc:char;
begin
cc:=a[aa];
a[aa]:=a[bb];
a[bb]:=cc;
end;
procedure ment(u:integer);
var
o:integer;
begin
if u=0 then begin for o:=1 to m do write(a[o]);writeln end
else for o:=1 to u do
begin
swap(m-u+o,m+1-u);
ment(u-1);
swap(m-u+o,m+1-u);
end;
end;
begin
for z:=1 to m do
begin
a[z]:=chr(z+64);
end;
ment(m);
readln
end.
const
m=10;
var
a:array[1..m] of char;
z:integer;
procedure swap(aa,bb:integer);
var
cc:char;
begin
cc:=a[aa];
a[aa]:=a[bb];
a[bb]:=cc;
end;
procedure ment(u:integer);
var
o:integer;
begin
if u=0 then begin for o:=1 to m do write(a[o]);writeln end
else for o:=1 to u do
begin
swap(m-u+o,m+1-u);
ment(u-1);
swap(m-u+o,m+1-u);
end;
end;
begin
for z:=1 to m do
begin
a[z]:=chr(z+64);
end;
ment(m);
readln
end.