program project1; var f:text;i,sum:integer;x0,y0:real;a,b,c,x,y:array [1..100] of real; procedure perevirka(x1,y1,x2,y2,x3,y3:real;var s:integer); begin if x1>=x2 then if y1>=y2 then if (x3>=x2) and (x3<=x1) and (y3>=y2) and (y3<=y1) then s:=s+1; if y1=x2) and (x3<=x1) and (y3<=y2) and (y3>=y1) then s:=s+1; if x1=x1) and (y3<=y2) and (y3>=y1) then s:=s+1; if y1>=y2 then if (x3<=x2) and (x3>=x1) and (y3>=y2) and (y3<=y1) then s:=s+1; end; begin assign(f,'Input.dat');reset(f); {Ïåðø³ äâ³ êîîðäèíàòè - öå êîîðäèíàòè ê³íö³â ïåðøîãî â³äð³çêà, à ³íø³ äâ³ - äðóãîãî} for i:=1 to 4 do readln(f,x[i],y[i]); close(f); assign(f,'output.sol');rewrite(f); a[1]:=y[2]-y[1]; b[1]:=x[1]-x[2]; c[1]:=-(a[1]*x[1]+b[1]*y[1]); a[2]:=y[4]-y[3]; b[2]:=x[3]-x[4]; c[2]:=-(a[2]*x[3]+b[2]*y[3]); x0:=(b[1]*c[2]-b[2]*c[1])/(a[1]*b[2]-a[2]*b[1]); y0:=-(a[1]*c[2]-a[2]*c[1])/(a[1]*b[2]-a[2]*b[1]); if x0=-0 then x0:=0; if y0=-0 then y0:=0; perevirka(x[1],y[1],x[2],y[2],x0,y0,sum); perevirka(x[3],y[3],x[4],y[4],x0,y0,sum); if sum=2 then write(f,'Tochka peretynu x=',x0:0:2,' y=',y0:0:2) else write(f,'Vidrizki ne peretynayutsia');close(f); end.