program trougao;
uses crt,graph;
function def:real;
  var Xasp,Yasp:word;
  begin
    GetAspectRatio(Xasp,Yasp);
    def:=Xasp/Yasp;
  end;
var driver,mode:integer;
    a,xc,yc,h:real;
begin
  ClrScr;
  writeln(' Program crta jednakostranicni trougao');
  writeln;
  write(' Unesi velicinu stranice trougla u pixelima:');
  readln(a);
  driver:=detect;
  initgraph(driver,mode,'');
  xc:=GetMaxX/2;
  yc:=GetMaxY/2;
  h:=a*sqrt(3)/2;
  if (h<0) or (h>GetMaxY)
    then
      begin
        restorecrtmode;
        writeln(' Velicina mora biti u intervalu [0,',round(GetMaxY*2/sqrt(3)),']!');
        write(' (pritisni <enter> za kraj)');
        readln
      end
    else
    begin
      moveto(round(xc-a/2),round(yc+h/3));
      LineRel(round(a),0);
      LineRel(-round(a/2),-round(h*def));
      LineRel(-round(a/2),round(h*def));
      readln;
      closegraph
    end
end.