урок на делфи 28 - 5 операторов и одна задача


задание на delphi. пять способов написать одну программу


unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x:integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if 3+x=7 then
Label1.Caption:='ответ x='+IntToStr(x)
else
begin
Label1.Caption:='ответ неправильный x<>'+IntToStr(x);
x:=x+1;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
for I := 0 to 10 do
begin
if 3+i=7 then
Label1.Caption:='ответ x='+IntToStr(i)
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
while 3+x<>7 do
begin
x:=x+1;
Label1.Caption:='ответ неправильный x<>'+IntToStr(x);
end;
Label1.Caption:='ответ x='+IntToStr(x)
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
repeat
x:=x+1;
Label1.Caption:='ответ неправильный x<>'+IntToStr(x);
until
3+x=7;
Label1.Caption:='ответ x='+IntToStr(x);
end;
procedure TForm1.Button5Click(Sender: TObject);
label m;
begin
m:
if 3+x=7 then
Label1.Caption:='ответ x='+IntToStr(x)
else
begin
Label1.Caption:='ответ неправильный x<>'+IntToStr(x);
x:=x+1;
goto m;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
x:=0;
end;
end.



Скачать