Hola.:
Tengo el siguiente código para efectuar obtener pares de números al azar
entre el 1 y el 999, sin embargo, después de ejecutarlo encuentro números
repetidos y no tengo idea de que agregar para evitar esto.
Gracias de antemano.
Mario Alberto
Option Explicit
Option Base 1
Public jj As Long
Public Const iteration = 500
'*****************
'* Resampling Process
*
'*****************
Sub Resample()
Dim i As Long
Dim hold(999) As Single, Hold2(999) As Single
Randomize
For i = 1 To 999
Hold2(i) = i
Next i
For jj = 1 To iteration
For i = 1 To 999
hold(i) = Rnd
Next i
Call DoubleSort(999, hold, Hold2)
For i = 1 To 2
Cells(jj + 3, i) = Hold2(i)
Next i
Next jj
End Sub
'**************************************
'*Sorting Process - Sort array y based on array x
*
'**************************************
Sub DoubleSort(n As Long, x() As Single, y() As Single)
Dim xTemp As Double
Dim yTemp As Double
Dim i As Long
Dim j As Long
For j = 2 To n
xTemp = x(j)
yTemp = y(j)
For i = j - 1 To 1 Step -1
If (x(i) <= xTemp) Then GoTo 10
x(i + 1) = x(i)
y(i + 1) = y(i)
Next i
i = 0
10 x(i + 1) = xTemp
y(i + 1) = yTemp
Next j
End Sub
Leer las respuestas