Добавил:
Fragga
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:PascalDelphi / Многие готовые лабы за 1&2 сем. от Колесниковой М.Д. / L2Pr2 / Unit1
.pas unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
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 x,a,y:real;
begin
x:=StrToFloat(Edit1.text);
if x<=4 then a:=5+2*x
else
if x<=5 then a:=3
else a:=sqrt(x+1);
y:=2*a;
Label3.Caption:='a='+FloatToStr(a);
Label4.Caption:='y='+FloatToStr(y)
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close
end;
end.
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
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 x,a,y:real;
begin
x:=StrToFloat(Edit1.text);
if x<=4 then a:=5+2*x
else
if x<=5 then a:=3
else a:=sqrt(x+1);
y:=2*a;
Label3.Caption:='a='+FloatToStr(a);
Label4.Caption:='y='+FloatToStr(y)
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close
end;
end.