谁有递归的程式的例子啊,偶算成品成本时,需要用到递归的例子谁有给一个先

解决方案 »

  1.   

    随手写一个,计算累加和的。function test(iInput:integer):integer;
    begin
        if iInput=0 then
            Result:=0
        else
        begin
            inc(iInput,-1);
            Result:=iInput+test(iInput);
        end;
    end;
      

  2.   

    //递归清空文本框。我的 
    //函数
    procedure TFormCYBase.ClearText(AControl:TWinControl);
    var
      I: Integer;
    begin
      for I := 0 to AControl.ControlCount - 1 do    // Iterate
      begin
        //需清空处理控件
        if AControl.Controls[i] is TCustomEdit then
        begin
          (AControl.Controls[i] as TCustomEdit).Text:='';
        end;
        if AControl.Controls[i] is TCustomComboBox then
        begin
          (AControl.Controls[i] as TCustomComboBox).ClearSelection;
        end;
        //可以 作为 父亲的控件处理事件。
        if AControl.Controls[i] is TCustomControl  then
        begin
          ClearText(AControl.Controls[i] as TCustomControl);
        end;
      end;
    end;//调用
    procedure TFormCYBase.BitBtn1Click(Sender: TObject);
    begin
      ClearText(self);
    end;