program familijetrouglova; uses crt,graph; function def:real; var Xasp,Yasp:word; begin GetAspectRatio(Xasp,Yasp); def:=Xasp/Yasp; end; var driver,mode,n,d:integer; a,xc,yc,h,r:real; begin ClrScr; write(' Unesi velicinu stranice trougla u pixelima:'); readln(a); write(' Unesi duzinu familije (n) i razliku pluprecnika susednih trouglova:'); readln(n,d); n:=n-1; driver:=detect; initgraph(driver,mode,''); if (a>886) or (a<0) then begin restorecrtmode; writeln(' Velicina stranice mora biti u intervalu [0,886]!'); write(' (pritisni <enter> za kraj)'); readln end else begin xc:=GetMaxX/2; yc:=GetMaxY/2; h:=a*sqrt(3)/2; r:=a*sqrt(3)/3; 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)); while (n>=0) and (r>0) do begin a:=r*sqrt(3); MoveTo(round(xc-(a/2)),round(yc+r/2)); LineRel(round(a),0); LineRel(-round(a/2),-round(3*r/2)); LineRel(-round(a/2),round(3*r/2)); r:=r-d; dec(n) end; readln; closegraph end end. |
|