n个整数的集合中任意取r个数进行排列

    xiaoxiao2021-12-12  2

    type se=set of 1..100; var s:se;     n,r,num:integer;     a:array[1..100] of integer; procedure print; var i:integer; begin   inc(num);   for i:=1 to r do   write(a[i]:3);   writeln; end; procedure dep(t:integer); var i:integer; begin   if t>r then begin print;exit;end;   for i:=1 to n do   if i in s then   begin     a[t]:=i;     s:=s-[i];     dep(t+1);     s:=s+[i];   end; end; begin   readln(n,r);   s:=[1..n];   num:=0;   dep(1);   write('number=',num); end.
    转载请注明原文地址: https://ju.6miu.com/read-900325.html

    最新回复(0)