Closest-pair problem: Difference between revisions

m
→‎{{header|REXX}}: added whitespace.
m (→‎{{header|REXX}}: added/changed whitespace and comments.)
m (→‎{{header|REXX}}: added whitespace.)
Line 4,197:
if datatype(seed, 'W') then call random ,,seed /*seed for RANDOM (BIF) repeatability.*/
w= length(HI); w= w + (w//2==0) /*W: for aligning the output columns.*/
 
/*╔══════════════════════╗*/ do j=1 for N /*generate N random points*/
/*║ generate N points. ║*/ @x.j= random(LO, HI) /* " a " X */
Line 4,204 ⟶ 4,205:
minD= (@x.A - @x.B)**2 + (@y.A - @y.B)**2 /* distance between the 1st two points.*/
/* [↓] use of XJ & YJ speed things up.*/
do j=1 for N-1; xj= @x.j; yj= @y.j /*find minimummin distance between a point ··· */
do k=j+1 for N-j-1 /* ··· point and all the other (higher) points. */
sd= (xj - @x.k)**2 + (yj - @y.k)**2 /*compute squared distance from points.*/
if sd<minD then parse value sd j k with minD A B