Re...bhbhParfait !ROGER2327
Mais simpliste...
Dans notre série Pourquoi faire simple quand on peut faire compliqué ?, j'ai un faible pour ce code :Code:[B][COLOR="DarkSlateGray"]Sub MEDAILLE_FIELD() Dim i As Long, j As Long, k As Long, l As Long Dim m As Long, n As Long, x As Integer For i = 0 To 9 n = n + 1 For j = [B][I]i[/I][/B] To 9 For k = [I][B]j[/B][/I] To 9 For l = [B][I]k[/I][/B] To 9 x = i x = 10 * x + j x = 10 * x + k x = 10 * x + l m = m + 1 With Cells(m, n) .Value = x .NumberFormat = "0000" End With Next l Next k Next j m = 0 Next i MsgBox "Opération terminée." End Sub[/COLOR][/B]
Sub MEDAILLE_FIELD()
Dim i As Long, j As Long, k As Long, l As Long
Dim m As Long, n As Long, x As Integer
For i = 0 To 9
n = n + 1
For j = i + 1 To 9
For k = j + 1 To 9
For l = k + 1 To 9
x = i
x = 10 * x + j
x = 10 * x + k
x = 10 * x + l
m = m + 1
With Cells(m, n)
.Value = x
.NumberFormat = "0000"
End With
Next l
Next k
Next j
m = 0
Next i
MsgBox "Opération terminée."
End Sub
Sub MEDAILLE_FIELD1()
Dim i As Long, j As Long, k As Long, l As Long
Dim m As Long, n As Long, x As Integer
For i = 0 To 9
n = n + 1
For j = 0 To 9
For k = 0 To 9
For l = 0 To 9
If j <> i And k <> i And l <> i And k <> j And l <> j And l <> k Then
x = i
x = 10 * x + j
x = 10 * x + k
x = 10 * x + l
m = m + 1
With Cells(m, n)
.Value = x
.NumberFormat = "0000"
End With
End If
Next l
Next k
Next j
m = 0
Next i
MsgBox "Opération terminée."
End Sub
Il fait ce que tu souhaites (et tu trouveras 5040 permutations et 210 combinaisons pour 4 chiffres)
Bonjour à tous
Si quelqu'un ( à l'esprit épris de mathématiques) pouvait faire un petit résumé de ce que sont les combinaisons et les permutations.
Merci.
(Car vous avez semez des doutes dans mon esprit )
la liste de 0000 à 9999 est un arrangement avec répétitions de 4 chiffres choisis parmi 10 et comporte 10^4 possibilités.
Les arrangements sans répétitions (0000, 0001, 0012 ne sont entre autre pas pris en compte) sont au nombre de 10!/(10-4)!=5040 possibilités.
Les combinaisons (0123 et 3210 sont la même combinaison, l'ordre ne rentrant pas en compte) sans répétitions sont au nombre de 10!/(4!(10-4)!)=210 possibilités différentes.
Pour les combinaisons avec répétitions il y a 13!/(4!(13-4)!)=715 possibilités.
Re
Mais pourquoi alors dans Excel, il utilise cette dénomination ?
=PERMUTATION(10;4) --> 5040
Comme souvent.(...) Excel utilise donc ici une dénomination incorrecte d'un terme (...)
Re : combinaisons
Suis vraiment desole
ce que je cherche c'est toutes les combainaisons possible de 0 à 9 a 4 chifre seulement
example
0098
4590
1205
9059
1574
1417
merci mes amis