|
|
вернуться в форумWhat's wrong with my answer. Help, please. Послано meoden 15 июн 2002 19:47 Here's my source code: {$r+,n+,q+,b-} const maxn=10000; var x,y:array[1..maxn] of longint; a:array[1..maxn] of real; b:array[1..maxn] of integer; n:integer; min,a1,a2:longint; procedure nhap; var i:integer; begin readln(n); min:=maxlongint; for i:=1 to n do begin readln(x[i],y[i]); if (y[i]<min) or ((y[i]=min) and (x[i]>x[a1])) then begin min:=y[i]; a1:=i; end; end; end; procedure shellsort; var i,j,h,tb:integer; ta:real; begin h:=n shr 1; while h<>0 do begin for i:=h+1 to n do begin ta:=a[i]; tb:=b[i]; j:=i-h; while (j>0) and (a[j]>ta) do begin a[j+h]:=a[j]; b[j+h]:=b[j]; j:=j-h; end; a[j+h]:=ta; b[j+h]:=tb; end; h:=h shr 1; end; end; function angle(i,j:integer):real; var dx,dy,ax,ay:longint; t:real; begin dx:=x[j]-x[i]; ax:=abs(dx); dy:=y[j]-y[i]; ay:=abs(dy); if (dx=0) and (dy=0) then t:=0 else t:=dy/(ax+ay); if dx<0 then t:=2-t else if dy<0 then t:=4+t; angle:=t*90; end; procedure init; var i:integer; begin for i:=1 to n do a[i]:=angle(a1,i); for i:=1 to n do b[i]:=i; end; begin nhap; init; shellsort; writeln(a1,' ',b[n div 2+1]); end. |
|
|