unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
Panel1: TPanel;
Label1: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit7: TEdit;
Edit8: TEdit;
Label5: TLabel;
Label6: TLabel;
Button1: TButton;
Edit9: TEdit;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
CheckBox1: TCheckBox;
procedure Button1Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
Procedure kuerze(a,b:integer;
var c,d:integer);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
z,n,x1,x2,a,p,px,p2,q,disk,p5,e: real;
begin
a:= strtofloat(edit1.text) / strtofloat(edit2.text);
px:= strtofloat(edit3.text) / strtofloat(edit4.text);
p:=px / a;
q:= (strtofloat(edit5.text) / strtofloat(edit6.text))/a;
p2:=p / 2;
disk:=sqr(p2) -q;
if disk<0
then begin
edit7.text:='
';
edit8.text:='
';
edit9.text:='
Keine Lösung'
end
else if disk>0
then begin
edit9.text:='
Zwei Lösungen';
x1:=-p/2+sqrt(disk);
x1:=round(x1 * 100) / 100 ;
x2:=p/2+sqrt(disk);
x2:=round(x2 * 100) / 100 ;
edit7.text:='
'+floattostr(x1);
edit8.text:='
'+floattostr(x2);
end
else if disk=0
then begin
edit9.text:='
Eine Lösungen';
e:=-p/2;
x1:=e;
x1:=round(x1 * 100) / 100;
edit7.text:='
'+floattostr (x1);
edit8.text:='
';
end;
end;
var z,n:real;
begin
z:=strtofloat (form1.edit1.text);
n:=strtofloat(form1.edit2.text);
tform1.kuerze (z,n,z1,n1);
edit1.text:=inttostr(z1);
edit2.text:=inttostr(n1);
end;
end;
end;
Procedure TForm1.kuerze(a,b:real;
var c,d:real);
var teiler:real;
begin
teiler:=a;
while (a
mod teiler <> 0)
or (b
mod teiler <>0)
do
teiler:=teiler-1;
c:=a
div teiler;
d:=b
div teiler;
end;