tezzwr 发表于 2012-8-17 20:38:39

小甲鱼老师交给的作业,完成了,上交。呵呵

小甲鱼老师在函数第三课的作业 交换数据,上交,请小甲鱼老师审批
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure swap(var str_a:string; var str_b: string);
private
    { Private declarations }
public
    { Public declarations }
end;

var
Form1: TForm1;

implementation


{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
   str1: string;
str2: string;

begin
str1:= edit1.Text ;
str2:= edit2.Text ;

swap(str1, str2);

edit1.Text := str1;
edit2.Text := str2;

end;
procedure TForm1.swap(var str_a: string; var str_b: string);
var

temp: string;
begin
temp:= str_a;
str_a:= str_b;
str_b:= temp;
end;

end.

tezzwr 发表于 2012-8-18 07:35:45

小甲鱼老师与各位老师,要把这个交换的过程写成函数的方式,要返回两个数据,要怎么写呀,本人是初学,真的还没弄明白,请各位老师指点下。

Angel丶L 发表于 2015-2-2 00:55:21

逛一逛,瞧一瞧,顶一顶,没坏处
页: [1]
查看完整版本: 小甲鱼老师交给的作业,完成了,上交。呵呵