如题。

解决方案 »

  1.   

    求组合n中取m,按照公式应为n!/(m!*(n-m)*(n-m-1)*……*1),则程序如下:
    procedure TForm1.Button1Click(Sender: TObject);
    var m,n,c,nj,i,mj,k:integer;
    begin
        nj:=1;//n的阶乘
        mj:=1;//m的阶乘
        k:=1;
        m:=strtoint(Edit1.Text);
        n:=strtoint(Edit2.Text);
        For i:=1 to n do
        nj:=i*nj;
        For i:=1 to m do
        mj:=i*mj;
        For i:=1 to n-m do
        k:=i*k;
        c:=nj div (mj*k);
        showmessage(inttostr(c));//c是结果
    end;
      

  2.   

    type
      TLibaryValue = array [1..10] of Integer;
      PLibaryValue = ^TLibaryValue;
      TListValue = array [1..10, 1..10] of Integer;var
      TLV: TLibaryValue;procedure TMainForm.CycForth();
    var
       N1, N2, N3, N4 : Integer;
    begin
      for N1 := 1 to MaxNum do
      begin
        TLV[1] := N1;
        for N2 := N1 + 1 to MaxNum do
        begin
          TLV[2] := N2;
          for N3 := N2 + 1 to MaxNum do
          begin
            TLV[3] := N3;
            for N4 := N3 + 1 to MaxNum do
            begin
              TLV[4] := N4;
              AddResultIntoList(TLV);
            end;
          end;
        end;
      end;
    end;