Listing: GALERIE.PAS const ni='input.txt'; no='output.txt'; type colt=record x,y:Integer end; var g:array[1..1001] of colt; n,i,maxx,minx,maxy,miny:Integer; function min(a,b:Integer):Integer; begin if a<b then min:=a else min:=b; end; function max(a,b:Integer):Integer; begin if a>b then max:=a else max:=b; end; Begin Assign(input,ni); Reset(input); Readln(n); for i:=1 to n do Readln(g[i].x,g[i].y); g[n+1]:=g[1]; minx:=-1; miny:=-1; maxx:=1001; maxy:=1001; for i:=1 to n do if g[i].x=g[i+1].x then if g[i].y<g[i+1].y then minx:=max(minx,g[i].x) else maxx:=min(maxx,g[i].x) else if g[i].x<g[i+1].x then maxy:=min(maxy,g[i].y) else miny:=max(miny,g[i].y); Assign(output,no); Rewrite(output); if (minx>maxx) or (miny>maxy) then Writeln('NO POINT') else Writeln((minx+maxx) div 2, ' ',(miny+maxy) div 2) End. [cuprins] |