salut , une propositon sous excel
Sub classement()
t = Array(120, 5, 8, 3, 17, 2, 11, 5, 8, 6, 1, 21, 17)
For i = 0 To UBound(t) - 1
For j = i + 1 To UBound(t)
If t(i) > t(j) Then
a = t(i)
b = t(j)
t(j) = a
t(i) = b
End If
Next
Next
For k = UBound(t) To 0 Step -1 'ordre decroissant
z = z & " " & t(k)
Next
MsgBox z 'c'est classé et cela retourne --> 120,21,17,17,11,8,8,6,5,5,3,2,1
'2 ieme partie:
'cration d 'un tableau ne contenant pas de repetitions qui servira à denombrer les termes se repetants:
t = Array(120, 5, 8, 3, 17, 2, 11, 5, 8, 6, 1, 21, 17)
For i = 0 To UBound(t) - 1
For j = i + 1 To UBound(t)
If t(i) = t(j) Then
t(j) = ""
End If
Next
Next
For k = 0 To UBound(t)
If t(k) <> "" Then
w = w & " " & t(k)
End If
Next
MsgBox w
s = Split(w, " ")
t = Array(120, 5, 8, 3, 17, 2, 11, 5, 8, 6, 1, 21, 17)
For j = 1 To UBound(s)
n = 0
For h = 0 To UBound(t)
If Val(s(j)) = Val(t(h)) Then
n = n + 1
End If
Next
If n > 1 Then
repet = repet + 1
End If
Next
MsgBox repet '--> donne 3 nombres qui se repetent
End Sub