Георгий Пикуза
S:11:00:40 28.11
R:11:00:41 28.11
program project1;
uses Graph;
const
N1 = 100;
type
tPoint = record
x,y : real;
end;
tCircle = record
r:integer;
o:tPoint;
end;
tTreangle = record
A,B,C : tPoint;
end;
function PointDist( p1, p2 : tPoint) :real;
begin
PointDist:=sqrt(sqr(p1.x-p2.x) + sqr(p1.y-p2.y));
end;
function TrgInCircle ( T1 : tTreangle;o1: tCircle ) : boolean;
begin
TrgInCircle:=(PointDist(o1.o,t1.a) < o1.r) and
(PointDist(o1.o,t1.b) < o1.r) and
(PointDist(o1.o,t1.c) < o1.r);
end;
function SquareTrg(T :tTreangle) : real;
var
ab, bc, ca, pp : real;
begin
ab:=PointDist( t.a, t.b );
bc:=PointDist( t.a, t.b );
ca:=PointDist( t.a, t.b );
pp:= (ab + bc + ca )/2.0;
SquareTrg:=sqrt(pp*(pp-ab)*(pp-bc)*(pp-ca));
end;
function VectPr( V00, V01,
V10, V11 : tPoint ):real;
var
v1x, v1y, v2x, v2y : real;
begin
v1x := V01.x - V00.x;
v1y := V01.y - V00.y;
v2x := V11.x - V10.x;
v2y := V11.y - V10.y;
VectPr := v1x*v2y - v2x*v1y;
end;
function PointInTreangle( P : tPoint;
T : tTreangle ) : boolean;
var
vp1, vp2,vp3 : real;
begin
vp1 := VectPr( T.A, P, T.A, T.B );
vp2 := VectPr( T.B, P, T.B, T.C );
vp3 := VectPr( T.C, P, T.C, T.A );
PointInTreangle := ( vp1*vp2 >= 0 ) and
( vp2*vp3 >= 0 ) and
( vp1*vp3 >= 0 )
end;
var
Ca : array [1..N1] of tCircle;
Pa : array [1..N1] of tPoint;
Ta : array [1..N1] of tTreangle;
N, Nt, Nc, i, j, k, max : integer;
t_max: tTreangle;
c_max: tCircle;
p_max: tpoint;
s, s_max: real;
F : Text;
d,m : SmallInt;
xm,ym: integer;
begin
Assign( F, *gr1.txt* );
Reset(F);
Nt:=0;
while not EoF(F) do begin
Nt := Nt+1;
Readln( F, Ta[Nt].A.x, Ta[Nt].A.y,
Ta[Nt].B.x, Ta[Nt].B.y,
Ta[Nt].C.x, Ta[Nt].C.y );
end;
Close(F);
Assign( F, *gr2.txt* );
Reset(F);
Nc:=0;
while not EoF(F) do begin
Nc := Nc+1;
Readln( F, ca[Nc].o.x, Ca[Nc].o.y, Ca[Nc].r);
end;
Close(F);
for i:=1 to N do
write( Pa[i].x:8:3, Pa[i].y:8:3, * * );
writeln;
for i:=1 to Nt do
writeln( Ta[i].A.x:8:3, Ta[i].A.y:8:3, * == *,
Ta[i].B.x:8:3, Ta[i].B.y:8:3, * == *,
Ta[i].C.x:8:3, Ta[i].C.y:8:3 );
writeln;
max:=0;
for i:=1 to Nc do begin
k:=0;
for j:=1 to Nt do begin
if TrgInCircle( ta[j], ca[i] ) then begin
writeln(*circle[*,i,*]*,* trg[*,j,*]*);
k:=k+1;
end;
end;
writeln(*circle [*,i,*], kol=*,k,* *);
if max < k then begin
max:=k;
c_max:=ca[i];
end;
end;
writeln (max);
writeln ( *circle[x = *,c_max.o.x:7:2,*, y = *, c_max.o.y:7:2,*, r = *,c_max.r,*]*);
writeln;
InitGraph(d,m,**);
xm := GetMaxX;
ym := GetMaxY;
writeln(*xm=*,xm,* *,*ym=*,ym );
for i:=1 to Nc do
Circle( round(ca[i].o.x), round(ca[i].o.y), ca[i].r );
for i:=1 to Nt do begin
Line (round(Ta[i].A.x), round(Ta[i].A.y),
round(Ta[i].B.x), round(Ta[i].B.y) );
Line (round(Ta[i].A.x), round(Ta[i].A.y),
round(Ta[i].C.x), round(Ta[i].C.y) );
Line (round(Ta[i].C.x), round(Ta[i].C.y),
round(Ta[i].B.x), round(Ta[i].B.y) );
end;
setcolor (red);
Circle( round(c_max.o.x), round(c_max.o.y), c_max.r );
readln;
end.