X xyf2001721 Unregistered / Unconfirmed GUEST, unregistred user! 2004-03-03 #1 例如:4中选3个,有(1,2,3),(1,2,4),(1,3,4),(2,3,4)
Y yostgxf Unregistered / Unconfirmed GUEST, unregistred user! 2004-03-03 #2 C(n,m)=n!/(m!*(n-m)!) function Permute(N, M): Integer; var I: Integer; begin Result:= M; for I:= M + 1 to Ndo Result:= Result * I; end; function Combin(N, M): Integer; begin Result:= Permute(N, M) div Permut(M, M); end;
C(n,m)=n!/(m!*(n-m)!) function Permute(N, M): Integer; var I: Integer; begin Result:= M; for I:= M + 1 to Ndo Result:= Result * I; end; function Combin(N, M): Integer; begin Result:= Permute(N, M) div Permut(M, M); end;
I iie Unregistered / Unconfirmed GUEST, unregistred user! 2004-03-04 #3 标记n然后叠代 procedure enum_(var aset, aresult, level); var i: integer; begin for i := 1 to ndo if not aset then begin aset := true; aresult[level] := i; end; if level = m then outputresult else enum_(aset, aresult, level + 1); end;
标记n然后叠代 procedure enum_(var aset, aresult, level); var i: integer; begin for i := 1 to ndo if not aset then begin aset := true; aresult[level] := i; end; if level = m then outputresult else enum_(aset, aresult, level + 1); end;
C creation-zy Unregistered / Unconfirmed GUEST, unregistred user! 2004-03-04 #4 请看: http://www.delphibbs.com/delphibbs/dispq.asp?lid=990544 为了节约空间,代码就不贴了。