Загрузка данных


unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    CheckBox1: TCheckBox;
    RadioGroup1: TRadioGroup;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Edit1.Text := '0';    // íà÷àëüíûé x
  Edit2.Text := '-0,5';  // íà÷àëüíûé y
  Label4.Caption := '';
  Memo1.Clear;

  Memo1.Lines.Add('Ëàáîðàòîðíàÿ Ðàáîòà N2');
  RadioGroup1.ItemIndex := 0; // Ïåðâîíà÷àëüíî íà sh(x)
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
var
  x, y, s, f: Extended;
  st: String;
begin
  x := StrToFloat(Edit1.Text);
  y := StrToFloat(Edit2.Text);

  case RadioGroup1.ItemIndex of
    0: f := Sinh(x); // sh(x)
    1: f := Sqr(x);  // x^2
    2: f := Exp(x);  // e^x
  end;
  // Ðàñ÷åò âåòîê
  if (y > -1) and (y < x) then
  begin
    s := Sin(4 * f + 2 * y);
    st := 'Âåòâü 1';
  end
  else if x > y then
  begin
    s := Cos(Abs(f * y)) + Power(f, 3);
    st := 'Âåòâü 2';
  end
  else // x = y
  begin
    s := Sqr(f + y);
    st := 'Âåòâü 3';
  end;
  Label4.Caption := st;

    if CheckBox1.Checked then
    Memo1.Lines.Add('Ðåçóëüòàò s = ' + IntToStr(Round(s)))
  else
    Memo1.Lines.Add('Ðåçóëüòàò s = ' + FloatToStrF(s, ffGeneral, 8, 2));
end;
end.