有意思,应该可以解决。procedure TForm1.Button1Click(Sender: TObject);Const N=10; M=4; X=20;Var NumArr:array [0..N-1] Of Integer; K:Integer; Function GetNextNum(StarIndex,Count:Integer; NeedVal:Integer; LastStr:String):Boolean; Var K2:Integer; begin K2:=StarIndex; While K2<= (N-Count) Do begin if Count=1 then begin IF NumArr[K2]=NeedVal Then Begin System.Delete(LastStr,1,1); Memo1.Lines.Add( LastStr+','+IntToStr(NumArr[K2]) ); end; end else GetNextNum( K2+1, Count-1, NeedVal-NumArr[K2], LastStr+','+IntToStr(NumArr[K2]) ); Inc(K2); end; End;begin For K:=LOW(NumArr) TO High(NumArr) do NumArr[K]:=K+1; GetNextNum( 0, M, X, '');end;给分!