
06.04.2010, 18:52
|
Прохожий
|
|
Регистрация: 06.04.2010
Сообщения: 3
Репутация: 10
|
|
Проверьте пож код, есть ли там ошибки
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Label4: TLabel;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
katet, gepot, visota, S: real;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var x:real;
begin
//если известен только катет
if RadioButton1.Checked=true then
begin
//считаем гепотенузу
katet:=strtofloat(Edit1.Text);
gepot:=sqrt((sqr(katet)+sqr(katet)));
//считаем высоту
visota:=(gepot/2);
//считаем площадь
S:=katet*katet/2;
//выводим на экран
Edit2.Text:=floattostr(gepot);
Edit3.Text:=floattostr(visota);
Edit4.Text:=floattostr(S);
end;
//если известна только гепотенуза
if RadioButton2.Checked=true then
begin
gepot:=strtofloat(Edit2.Text);
//считаем высоту
visota:=(gepot/2);
//считаем катет
katet:=sqrt(sqr(visota)+sqr(gepot/2));
//считаем площадь
S:=katet*katet/2;
//выводим на экран
Edit1.Text:=floattostr(katet);
Edit3.Text:=floattostr(visota);
Edit4.Text:=floattostr(S);
end;
//если известна только высота
if RadioButton3.Checked=true then
begin
visota:=strtofloat(Edit3.Text);
//считаем гепотенузу
gepot:=2*visota;
//считаем катет
katet:=sqrt(sqr(visota)+sqr(gepot/2));
//считаем площадь
S:=katet*katet/2;
//выводим на экран
Edit1.Text:=floattostr(katet);
Edit2.Text:=floattostr(gepot);
Edit4.Text:=floattostr(S);
end;
//если известна только площадь
if RadioButton4.Checked=true then
begin
S:=strtofloat(Edit4.Text);
//считаем катет
katet:=sqrt(2*S);
//считаем гепотенузу
gepot:=sqrt(sqr(katet)+sqr(katet));
//считаем высоту
visota:=(gepot/2);
//выводим на экран
Edit1.Text:=floattostr(katet);
Edit2.Text:=floattostr(gepot);
Edit3.Text:=floattostr(visota);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Text:='0';
Edit2.Text:='0';
Edit3.Text:='0';
Edit4.Text:='0';
end;
end.
Admin: Пользуемся тегами!
|