Tri à bulles en python 3.0 à partir d'un algorithme
Résolu
youterk
Messages postés
192
Date d'inscription
Statut
Membre
Dernière intervention
-
geekette89 -
geekette89 -
Bonjour,
voilà l'algorithme que j'ai à mettre en python :
Données : Une liste à trier notée L
Résultat : une liste L triée
Variables : k, temp : entier
début bloc principal
k <- -1 ;
tant que k < taille(L) faire
k <- k+1;
si L[k]>L[k+1] alors
temp <- L[k];
L[k] <- L[k+1];
L[k+1] <- temp;
k <- -1;
moi j'ai fait :
k=-1
while k < len(L):
k=(k+1)
if L[k] > L[k+1]:
temp=L[k]
L[k]=L[k+1]
L[k+1]=temp
k=-1
On doit juste présenter ça sous forme d'une fonction, mais ça me mets avec aptana qu'il y a un problème à " if L[k] > L[k+1]"
aidez-moi s'il vous plaît
voilà l'algorithme que j'ai à mettre en python :
Données : Une liste à trier notée L
Résultat : une liste L triée
Variables : k, temp : entier
début bloc principal
k <- -1 ;
tant que k < taille(L) faire
k <- k+1;
si L[k]>L[k+1] alors
temp <- L[k];
L[k] <- L[k+1];
L[k+1] <- temp;
k <- -1;
moi j'ai fait :
k=-1
while k < len(L):
k=(k+1)
if L[k] > L[k+1]:
temp=L[k]
L[k]=L[k+1]
L[k+1]=temp
k=-1
On doit juste présenter ça sous forme d'une fonction, mais ça me mets avec aptana qu'il y a un problème à " if L[k] > L[k+1]"
aidez-moi s'il vous plaît