unit Unit4;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,math;

type
  TForm4 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Edit1: TEdit;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    function GetHeight(a,b,c,storona:integer):extended;
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form4: TForm4;
  i,a,b,c,curl,mark:integer;
  bigest,lang,s1:string;
  vals,mm:array[0..2]of integer;
  f1:textfile;
  vidp1:extended;
implementation

{$R *.dfm}

function tform4.GetHeight(a,b,c,storona:integer):extended;
var
s,p:extended;
begin
p:=(a+b+c)/2;
if (p*(p-a)*(p-b)*(p-c))<=0 then
result:=0
else
begin
s:=sqrt(p*(p-a)*(p-b)*(p-c));
result:=s/storona;
end;
end;

procedure TForm4.Button1Click(Sender: TObject);
begin
close;
end;

procedure TForm4.FormCreate(Sender: TObject);
begin
curl:=0;
randomize;
button4.Hide;
button3.Hide;
label1.Caption:='';
label2.Hide;
edit1.Hide;
label3.Caption:='';
end;

procedure TForm4.Button2Click(Sender: TObject);
begin
vidp1:=0;
case curl{/lpr}+1 of
1:while vidp1=0 do begin
randomize;
a:=random(100)+1;
b:=random(100)+1;
c:=random(100)+1;
vals[0]:=a;
vals[1]:=b;
vals[2]:=c;
if MaxIntValue(vals)=a then bigest:='a';
if MaxIntValue(vals)=b then bigest:='b';
if MaxIntValue(vals)=c then bigest:='c';
if bigest='a' then vidp1:=getheight(a,b,c,a);
if bigest='b' then vidp1:=getheight(a,b,c,b);
if bigest='c' then vidp1:=getheight(a,b,c,c);
end;
2:while vidp1=0 do begin
randomize;
a:=random(100)+1;
b:=random(100)+1;
c:=random(100)+1;
vals[0]:=a;
vals[1]:=b;
vals[2]:=c;
if MinIntValue(vals)=a then bigest:='a';
if MinIntValue(vals)=b then bigest:='b';
if MinIntValue(vals)=c then bigest:='c';
if bigest='a' then vidp1:=getheight(a,b,c,a);
if bigest='b' then vidp1:=getheight(a,b,c,b);
if bigest='c' then vidp1:=getheight(a,b,c,c);
end;
3:while vidp1=0 do begin
randomize;
a:=random(100)+1;
b:=random(100)+1;
c:=random(100)+1;
vals[0]:=a;
vals[1]:=b;
vals[2]:=c;
if ((minintvalue(vals)=b)and(maxintvalue(vals)=c))or
((minintvalue(vals)=c)and(maxintvalue(vals)=b)) then bigest:='a';
if ((minintvalue(vals)=c)and(maxintvalue(vals)=a))or
((minintvalue(vals)=a)and(maxintvalue(vals)=c)) then bigest:='b';
if ((minintvalue(vals)=b)and(maxintvalue(vals)=a))or
((minintvalue(vals)=a)and(maxintvalue(vals)=b)) then bigest:='c';
if bigest='a' then vidp1:=getheight(a,b,c,a);
if bigest='b' then vidp1:=getheight(a,b,c,b);
if bigest='c' then vidp1:=getheight(a,b,c,c);
end;
end;
button3.Show;
label2.Show;
edit1.Show;
button2.Hide;
//if mm[lpr]=0 then
if lang='ua' then
case curl{/lpr}+1 of
1:label1.Caption:='Äàíî: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Çíàéòè íàéá³ëüøó âèñîòó.';
2:label1.Caption:='Äàíî: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Çíàéòè íàéìåíøó âèñîòó.';
3:label1.Caption:='Äàíî: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Çíàéòè ñåðåäíþ âèñîòó.';
end
else
if lang='en' then
case curl{/lpr}+1 of
1:label1.Caption:='Given: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Find largest height.';
2:label1.Caption:='Given: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Find smallest height.';
3:label1.Caption:='Given: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Find average height.';
end
else
if lang='ru' then
case curl{/lpr}+1 of
1:label1.Caption:='Äàíî: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Íàéòè íàèáîëüøóþ âûñîòó.';
2:label1.Caption:='Äàíî: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Íàéòè íàèìåíüøóþ âûñîòó.';
3:label1.Caption:='Äàíî: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Íàéòè ñðåäíþþ âûñîòó.';
end;
writeln(f1,label1.caption);
end;

procedure TForm4.Button3Click(Sender: TObject);
var
uservidp:integer;
begin
curl:=curl+1;
button3.Hide;
button4.Show;
edit1.Enabled:=false;
button3.Hide;
uservidp:=0;
if edit1.Text<>'' then uservidp:=strtoint(edit1.Text);
writeln(f1,'vidp:',uservidp);
writeln(f1,'');
if (uservidp>vidp1-0.2)and(uservidp<vidp1+0.2) then begin
if lang='ua' then
s1:='Â³ðíî!'
else
if lang='en' then
s1:='True!'
else
if lang='ru' then
s1:='Âåðíî!';
label3.Caption:=s1;
mark:=mark+4;
writeln(f1,'!!!OK!!!');
writeln(f1,'');
end
else begin
if lang='ua' then
s1:='Ïîìèëêà! Ïðàâèëüíà â³äïîâ³äü: '
else
if lang='en' then
s1:='Error! Correct answer: '
else
if lang='ru' then
s1:='Îøèáêà! Ïðàâèëüíûé îòâåò: ';
label3.caption:=s1+floattostr(vidp1);
writeln(f1,'!!!ERROR!!!');
writeln(f1,'');
end;
end;

procedure TForm4.Button4Click(Sender: TObject);
begin
edit1.Text:='';
button4.Hide;
button3.Show;
edit1.Enabled:=true;
label3.Caption:='';
if curl=3 then begin
if mark=0 then mark:=1;
if lang='ua' then
s1:='Âàøà îö³íêà :'
else
if lang='en' then
s1:='Your mark :'
else
if lang='ru' then
s1:='Âàøà îöåíêà :';
label3.Caption:=s1+inttostr(mark);
writeln(f1,'!!!'+label2.caption+'!!!');
button3.Hide;
edit1.Enabled:=false;
end
else
begin
vidp1:=0;
case curl{/lpr}+1 of
1:while vidp1=0 do begin
randomize;
a:=random(100)+1;
b:=random(100)+1;
c:=random(100)+1;
vals[0]:=a;
vals[1]:=b;
vals[2]:=c;
if MaxIntValue(vals)=a then bigest:='a';
if MaxIntValue(vals)=b then bigest:='b';
if MaxIntValue(vals)=c then bigest:='c';
if bigest='a' then vidp1:=getheight(a,b,c,a);
if bigest='b' then vidp1:=getheight(a,b,c,b);
if bigest='c' then vidp1:=getheight(a,b,c,c);
end;
2:while vidp1=0 do begin
randomize;
a:=random(100)+1;
b:=random(100)+1;
c:=random(100)+1;
vals[0]:=a;
vals[1]:=b;
vals[2]:=c;
if MinIntValue(vals)=a then bigest:='a';
if MinIntValue(vals)=b then bigest:='b';
if MinIntValue(vals)=c then bigest:='c';
if bigest='a' then vidp1:=getheight(a,b,c,a);
if bigest='b' then vidp1:=getheight(a,b,c,b);
if bigest='c' then vidp1:=getheight(a,b,c,c);
end;
3:while vidp1=0 do begin
randomize;
a:=random(100)+1;
b:=random(100)+1;
c:=random(100)+1;
vals[0]:=a;
vals[1]:=b;
vals[2]:=c;
if ((minintvalue(vals)=b)and(maxintvalue(vals)=c))or
((minintvalue(vals)=c)and(maxintvalue(vals)=b)) then bigest:='a';
if ((minintvalue(vals)=c)and(maxintvalue(vals)=a))or
((minintvalue(vals)=a)and(maxintvalue(vals)=c)) then bigest:='b';
if ((minintvalue(vals)=b)and(maxintvalue(vals)=a))or
((minintvalue(vals)=a)and(maxintvalue(vals)=b)) then bigest:='c';
if bigest='a' then vidp1:=getheight(a,b,c,a);
if bigest='b' then vidp1:=getheight(a,b,c,b);
if bigest='c' then vidp1:=getheight(a,b,c,c);
end;
end;

//if mm[lpr]=0 then
if lang='ua' then
case curl{/lpr}+1 of
1:label1.Caption:='Äàíî: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Çíàéòè íàéá³ëüøó âèñîòó.';
2:label1.Caption:='Äàíî: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Çíàéòè íàéìåíøó âèñîòó.';
3:label1.Caption:='Äàíî: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Çíàéòè ñåðåäíþ âèñîòó.';
end
else
if lang='en' then
case curl{/lpr}+1 of
1:label1.Caption:='Given: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Find largest height.';
2:label1.Caption:='Given: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Find smallest height.';
3:label1.Caption:='Given: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Find average height.';
end
else
if lang='ru' then
case curl{/lpr}+1 of
1:label1.Caption:='Äàíî: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Íàéòè íàèáîëüøóþ âûñîòó.';
2:label1.Caption:='Äàíî: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Íàéòè íàèìåíüøóþ âûñîòó.';
3:label1.Caption:='Äàíî: ÀÂ='+inttostr(a)+'ñì, ÀÑ='+inttostr(c)
+'ñì, ÂÑ='+inttostr(b)+'ñì. Íàéòè ñðåäíþþ âûñîòó.';
end;
writeln(f1,label1.caption);
end;
end;

procedure TForm4.FormShow(Sender: TObject);
begin
if lang='ua' then
begin
button1.Caption:='Çàêðèòè';
button2.Caption:='Ñòàðò';
button3.Caption:='Ïåðåâ³ðêà';
button4.Caption:='Ïðîäîâæåííÿ';
end
else
if lang='en' then
begin
button1.Caption:='Close';
button2.Caption:='Start';
button3.Caption:='Check';
button4.Caption:='Next';
end
else
if lang='ru' then
begin
button1.Caption:='Çàêðèòü';
button2.Caption:='Ñòàðò';
button3.Caption:='Ïðîâåðêà';
button4.Caption:='Ïðîäîëæèòü';
end;
if fileexists('statistic.txt')<>true then begin
assignfile(f1,'statistic.txt');
rewrite(f1);
end
else begin
assignfile(f1,'statistic.txt');
append(f1);
end;
writeln(f1,'Zadacha2');
end;

procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);
begin
closefile(f1);
end;

end.
