鱼C论坛

 找回密码
 立即注册
查看: 1865|回复: 0

谁帮我看下这个过程的使用有何不妥,从小到大排列三个数

[复制链接]
发表于 2014-2-23 01:32:49 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  procedure pailie(a,b,c:Integer);      //声明一个过程,有3个整数
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.pailie(a,b,c:Integer);   //定义过程,按照从小到大的顺序排列
var
  n:Integer;
  begin
    a:=StrToInt(Edit1.Text);
    b:=StrToInt(Edit2.Text);
    c:=StrToInt(Edit3.Text);
    if a<b then
    begin
    n:=b;
    b:=a;
    a:=n;
    end;
    if a<c then
    begin
    n:=c;
    c:=a;
    a:=n;
    end;
    if b<c then
    begin
    n:=c;
    c:=b;
    b:=n;
    end;
  end;

procedure TForm1.Button1Click(Sender: TObject);  //使用过程
var
  x,y,z:Integer;
begin
  pailie(x,y,z);                          //将过程的a,b,c 三个整数按照从大到小的顺序传给x,y,z
  Label1.Caption:=IntToStr(x) + ',' + IntToStr(y) +',' + IntToStr(z);  //显示出来
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Button1.Caption:='顺序排列';
Label1.Caption:='';
end;
end.

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-7-5 05:48

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表