unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 =
class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Button1: TButton;
Edit9: TEdit;
Edit10: TEdit;
Button4: TButton;
Button3: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
function ggT(x,y:Integer):Integer;
Begin
While x<>y
do
Begin
If x>y
then x:=x-y
else y:=y-x;
End;
result:=x;
End;
//------------------------------------------------
function kgV(x,y:Integer):Integer;
Begin
result:=x*y
div ggT(x,y);
End;
//------------------------------------------------
procedure kuerzen(
VAR a,b : Integer);
Var Teiler:Integer;
Begin
If (a<>0)
and (b<>0)
// ansonsten Sonderfälle !!!
then begin
Teiler:=ggT(a,b);
a:=a
div Teiler;
b:=b
div Teiler;
end;
End;
procedure TForm2.Button1Click(Sender: TObject);
var
a,b,a1,b1,a2,b2,c2,d2,a3,b3:integer;
begin
a:=strtoint(edit1.text);
b:=strtoint(edit2.text);
a1:=strtoint(edit6.text);
b1:=strtoint(edit7.text);
a2:=a*b1;
b2:=b*b1;
c2:=a1*b;
d2:=b1*b;
a3:=a2+c2;
b3:=d2;
kuerzen(a3,b3)
edit9.Text:=inttostr(a3);
edit10.Text:=inttostr(b3);