20 lines
431 B
Plaintext
20 lines
431 B
Plaintext
Procedure.d bruteForceClosestPair(Array P.coordinate(1))
|
|
Protected N=ArraySize(P()), i, j
|
|
Protected mindistance.f=Infinity(), t.d
|
|
Shared a, b
|
|
If N<2
|
|
a=0: b=0
|
|
Else
|
|
For i=0 To N-1
|
|
For j=i+1 To N
|
|
t=Pow(Pow(P(i)\x-P(j)\x,2)+Pow(P(i)\y-P(j)\y,2),0.5)
|
|
If mindistance>t
|
|
mindistance=t
|
|
a=i: b=j
|
|
EndIf
|
|
Next
|
|
Next
|
|
EndIf
|
|
ProcedureReturn mindistance
|
|
EndProcedure
|