unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
function proportion(a,b,c,d:real; xxx:string):real;
var
res:real;
begin
if xxx = 'a' then
begin
a:=(b*c)/d;
res:=a;
end;
if xxx = 'b' then
begin
b:=(b*c)/d;
res:=b;
end;
if xxx = 'c' then
begin
c:=(a*d)/b;
res:=c;
end;
if xxx = 'd' then
begin
d:=(b*c)/a;
res:=d;
end;
Result:=res;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
res:real;
begin
res:=proportion(15,3,0,2,'c');
ShowMessage('x='+FloatToStr(res));
end;
procedure TForm1.Button2Click(Sender: TObject);
var
res:real;
begin
res:=proportion(50,45,100,0,'d');
ShowMessage('x='+FloatToStr(res));
end;
end.