Bonjour
je voudrai savoir comment je peux afficher le k nombre consectifs de x ayant le plus grand produit
par exemple plusgrandconsecutifs([2,3,5,1,6],3)
ici je cherche le 3 valeurs consecutifs qui forme un grand nombre, doit renvoiyer [5,1,6]
volia ma solution
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 def exo7(liste,n): i=0 maxt=[0] maxi=1 pdt=1 for j in xrange(len(liste)): k=j pdt=1 print j while(i<n): pdt=pdt*liste[j] j=j+1 i=i+1 if pdt>=maxi: maxi=pdt while len(maxt)!=0: maxt.pop() maxt.append(liste[k]) i=i+1 j=k i=0 print maxt plusgrandconsecutifs([2,3,5,1,6],3)
pourrez vous m'aidez s'il vous plais
merci
Partager