1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| Sub testhyp()
Dim i As Long
Dim j As Long
Dim k As Integer
Dim n As Integer
Dim vari() As Double
Dim fl As Integer
Dim val As Integer
Dim nbrligneparonglet As Long
Dim t_deb As Single, t_fin As Single, tpass As Single
Dim resultatminimum As Double
'n variables
'k valeurs
Sheets("Hyp").Select
k = Range("b65536").End(xlUp).Row - 1
'k Valeur
n = Range("IV2").End(xlToLeft).Column - 1
t_deb = Timer
'on remplit le tableau avec les valeurs du n-uplet
ReDim vari(1 To n, 1 To k)
For i = 1 To n
For j = 1 To k
vari(i, j) = Feuil1.Cells(j + 1, i + 1)
Next j
Next i
'on écrit les n-uplets dans les différents onglets et on teste chaque n-upplet pour avoir le minimum
resultatminimum = Sheets(1).Cells(10, 3).Value
For i = 0 To k ^ n - 1
For j = 0 To n - 1
val = (i \ (k ^ j)) Mod (k)
Sheets(3).Cells(1, j + 1).Value = vari(j + 1, val + 1)
Sheets(1).Cells(6, 2 + j).Value = Sheets(3).Cells(1, j + 1)
Next j
If Sheets(1).Cells(10, 3).Value < resultatminimum Then
For j = 0 To n - 1
Sheets(1).Cells(16, 2 + j).Value = Sheets(1).Cells(6, 2 + j).Value
Next j
resultatminimum = Sheets(1).Cells(10, 3).Value
Else
'indique ici ce que tu veux faire en cas d'égalité par exemple
End If
Next i
t_fin = Timer
tpass = CSng(Round(t_fin - t_deb, 2))
MsgBox "Il faut " & tpass & " s pour tester les hypothèses"
End Sub |