Known all small array at the "dot" coordinates (x (n), y (n)), and in which coordinates contains the most circle with radius of a scope,
Added: such as n is 0 to 20, "dot" is random, the coordinates of the size of the plane for the 20 * 20
Randomize
For n=0 To 20
X (n)=int (RND * 20)
Y (n)=int (RND * 20)
Next
CodePudding user response:
I am using exhaustive method, the code is a bit cumbersome (because I am a beginner, and bad at math!)Came to the center coordinates are not necessarily only one so the return value is the number of,
I don't have the test code, if there is a problem continues!
Private Type PT
X As Long
Y As Long
End Type
Private Function GetPt (Pts) As PT) As PT () 'to a PT array to return to the center of the circle array
Dim the Up ((UBound (Pts)), 1) As an Integer, tmpUp As Integer
Dim tmpLong (UBound (Pts)) As Long
Dim I As an Integer, q As Integer
TmpUp=1
For I=0 To UBound (Pts)
For q=0 To UBound (Pts)
If I & lt;> Q Then
TmpLong (q)=CPt (Pts (I) and Pts (q))
End the If
Next
TmpUp=GetLongLenth (tmpLong)
For I=0 To UBound (Pts)
If the Up (I, 0) & lt;=tmpUp Then
The Up (I, 0)=tmpUp
The Up (I, 1)=I
The Exit For
End the If
Next
Next
Dim tmpUpNum As Integer
For I=0 To UBound (Pts)
If the Up (I, 0) & lt;> The Up (I + 1) Then
TmpUpNum=I
The Exit For
End the If
Next
Dim RPt (tmpUpNum) As PT
For I=0 To tmpUpNum
RPt (I)=Pts (Up (I, 1))
Next
GetPt RPt=
End the Function
Private Function CPt (Pt1 As PT, Pt2 As PT) As Long
CPt=((Pt1. X-ray Pt2. X) ^ 2 + (Pt1. Y - Pt2. Y) ^ 2) ^ (1/2)
End the Function
Private Function GetLongLenth (tmpLong ()) As Long As the Integer
Dim tmpNum As an Integer, tmpNum1 As Integer
Dim I, q
For I=0 To UBound (tmpLong)
TmpNum1=0
For q=0 To UBound (tmpLong)
If q & lt;> I And tmpLong (I)=tmpLong (q) Then
TmpNum1=tmpNum1 + 1
End the If
Next
If tmpNum1 & gt; TmpNum Then
TmpNum=tmpNum1
End the If
Next
GetLongLenth tmpNum=
End the Function
CodePudding user response:
The return value is an array of the above have the wrong numberCodePudding user response:
Kiss, ah, ah I know exhaustive method, if it is the whole desktop resolution size, 1024 * 768 * 20 that tends to more than one thousand cyclesCodePudding user response: