Delphi语法中的循环WHILE..DO和REPEAT..UNTIL
unit Unit1;
interface
us
Windows, Messages, SysUtils, Variants, Class, Graphics, Controls, Forms,万事皆休
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
寒门再难出贵子Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
珍惜所拥有的var
Form1: TForm1;
implementation
{$R *.dfm}
咖啡渣
procedure TForm1.Button1Click(Sender: TObject);
var odds,sum:integer;
begin八年级物理课本
sum:=0;
odds:=1;
while odds<= strtoint(Edit1.Text) do商务英语翻译
begin
sum:=sum+odds;
odds:=odds+2;
end;
Showmessage(inttostr(sum));
end;两元人民币
procedure TForm1.Button2Click(Sender: TObject);
var odds,sum:integer;
begin
sum:=0;
odds:=1;
Repeat
sum:=sum+odds;
odds:=odds+2;
until odds > strtoint(Edit1.Text);
Showmessage(inttostr(sum));
小学生的画
end;
end.
while..do是条件先⾏,repeat..until是条件后⾏,所以repeat..until的语法段⾥⾯⾄少要运⾏⼀次,Delphi给⼈的感觉学习起来没什么难度,主要还是有别的语⾔的基础吧,也主要是⾃⼰做多了⾯向对象的开发,总觉得Delphi7的IDE差微软的DOTNET级别的IDE远多了,⽤起来不是很顺⼿。