rendered paste bodyprogram antra19;
uses crt, graph;
var tvark, skgeb, xc, yc, plotis, aukstis, x, y:integer;
x2, y2, ats1, ats2, ats:real;
s, s2:string;
begin
clrscr;
writeln('Iveskite tasko koordinates: ');
read(x, y);
tvark:=detect;
skgeb:=0;
plotis:=800;
aukstis:=640;
xc:=plotis div 2;
yc:=aukstis div 2;
x2:=x;
y2:=y;
x:=x*30;
y:=y*30;
InitGraph(tvark, skgeb, 'E:\Progros\FPC\BGI\');
textmode(2);
SetViewPort(0, 0, plotis, aukstis+50, true);
SetFillStyle(1, 15); //nupiesiam fona
Bar(0, 0, plotis, aukstis);
SetColor(3); //piesiam apskritimus
setfillstyle(6, 3);
circle(xc+60, yc, 60);
floodfill(xc+60, yc, 3);
circle(xc-60, yc, 60);
floodfill(xc-60, yc, 3);
SetColor(4); //piesiam savo taska kaip apskritima kad ryskiau matytusi
setfillstyle(1, 4);
circle(xc+x, yc-y, 2);
floodfill(xc+x, yc-y, 4);
SetColor(0); //piesiam koordinaciu sistema
SetLineStyle(0, 0, 1);
line(0, yc, plotis-15, yc);
line(plotis-15, yc-3, plotis-15, yc+3);
line(plotis-15, yc-3, plotis, yc);
line(plotis-15, yc+3, plotis, yc);
line(xc, 15, xc, aukstis);
line(xc, 0, xc-3, 15);
line(xc, 0, xc+3, 15);
line(xc-3, 15, xc+3, 15);
setfillstyle(1, 0);
floodfill(xc, 10, 0);
floodfill(plotis-5, yc, 0);
outtextxy(plotis-20, yc+5, 'x'); //pazymim x ir y asis
outtextxy(xc-10, 15, 'y');
outtextxy(xc+60, yc-70, '2'); //apskritimu ribos
outtextxy(xc+60, yc+70, '-2');
outtextxy(xc-140, yc+10, '-4');
outtextxy(xc+130, yc+10, '4');
ats1:=sqrt(sqr(x2+2) + sqr(y2));
ats2:=sqrt(sqr(x2-2) + sqr(y2));
if ats1<ats2 then ats:=ats1
else ats:=ats2;
SetFillStyle(1, 4); //nupiesiam atsakymo isvedimo lauko fona
Bar(0, aukstis, plotis, aukstis+30);
setcolor(10);
settextstyle(4, 0, 1);
if ats<=2 then begin
ats:=sqrt(sqr(x2)+sqr(y2));
str(ats:3:2, s);
outtextxy(5, aukstis+10, 'Taskas patenka i uzstrichuota sriti, o atstumas iki koordinaciu pradzios yra ' + s + '.');
end
else begin
ats:=ats-2;
str(ats:3:2, s);
outtextxy(5, aukstis+10, 'Taskas nepatenka i uzstrichuota sriti, o artimiausias atstumas iki jos yra ' + s + '.');
end;
writeln('Press enter to continue...');
readln;
readln
end.