- 全排列
- 2009-07-11 21:43:20 @
var
a:array[1..100] of longint;
b:array[1..100] of boolean;
n,i,t,q,w:integer;
procedure search(depth:integer);
var
i:integer;
begin
if depth>n then
begin
inc(t);
if t=q then begin
for i:= 1 to n do
write(a[i],' ');
halt;
end;
exit;
end;
for i:= 1 to n do
if b[i]=false then
begin
a[depth]:=i;
b[i]:=true;
search(depth+1);
b[i]:=false;
end;
end;
begin
t:=0;
read(n,q);
fillchar(b,sizeof(b),false);
search(1);
end.
7 条评论
-
hsez_woixia1314 LV 10 @ 2016-07-27 11:38:14
这个 你重新写一遍就可以了
-
2009-08-20 16:25:54@
有没啊
-
2009-08-20 16:24:03@
有没
-
2009-08-12 21:40:55@
又没
-
2009-08-12 21:37:33@
还是没
-
2009-08-12 21:35:25@
没
-
2009-08-12 21:29:18@
自己抢
- 1