Besoin d'aide pour transformer prg visual basic
Publié : ven. 14/avr./2023 19:58
Bonjour à tous et merci de m'accepter sur le forum.
J'ai un programme que je n'arrive pas à transformer complètement en PureBasic. Alors si quelqu'un parmi vous peut m'aider, milles merci.
voici le programme :
J'ai un programme que je n'arrive pas à transformer complètement en PureBasic. Alors si quelqu'un parmi vous peut m'aider, milles merci.
voici le programme :
Code : Tout sélectionner
Dim chosenNumbers(5) As Integer
chosenNumbers(1) = 1
chosenNumbers(2) = 2
chosenNumbers(3) = 3
chosenNumbers(4) = 4
chosenNumbers(5) = 5
Dim numSequences As Integer = 200
Dim sequenceLength As Integer = 5
Dim minMatches As Integer = 4
Dim reducedNumSequences As Integer = 10
Dim sequences(numSequences, sequenceLength) As Integer
For i As Integer = 1 To numSequences
For j As Integer = 1 To sequenceLength
sequences(i, j) = CInt(Math.Floor((10 - 1 + 1) * Rnd())) + 1
Next j
Next i
Dim hasMatch As Boolean = False
For i As Integer = 1 To numSequences
Dim matchCount As Integer = 0
For j As Integer = 1 To sequenceLength
For k As Integer = 1 To 5
If sequences(i, j) = chosenNumbers(k) Then
matchCount += 1
End If
Next k
Next j
If matchCount >= minMatches Then
hasMatch = True
End If
Next i
If Not hasMatch Then
ReDim Preserve sequences(numSequences + 1, sequenceLength)
For i As Integer = 1 To minMatches
sequences(numSequences + 1, i) = chosenNumbers(i)
Next i
For i As Integer = minMatches + 1 To sequenceLength
sequences(numSequences + 1, i) = CInt(Math.Floor(((10 - minMatches) - (minMatches + 1) + 1) * Rnd())) + (minMatches + 1)
Next i
End If
Dim reducedSequences(reducedNumSequences, sequenceLength) As Integer
For i As Integer = 1 To reducedNumSequences
Dim sequenceIndex As Integer = CInt(Math.Floor(((numSequences + IIf(hasMatch, 0, 1)) - 1 + 1) * Rnd())) + 1
For j As Integer = 1 To sequenceLength
reducedSequences(i, j) = sequences(sequenceIndex, j)
Next j
Next i
For i As Integer = 1 To reducedNumSequences
For j As Integer = 1 To sequenceLength
Console.Write(reducedSequences(i, j))
Next j
Console.WriteLine()
Next i