Questions tagged «bubble-sort»

27
泡泡排序作业
在课堂上,我们正在做排序算法,尽管我在谈论它们并编写伪代码时理解得很好,但是我在为它们编写实际代码时遇到了问题。 这是我在Python中的尝试: mylist = [12, 5, 13, 8, 9, 65] def bubble(badList): length = len(badList) - 1 unsorted = True while unsorted: for element in range(0,length): unsorted = False if badList[element] > badList[element + 1]: hold = badList[element + 1] badList[element + 1] = badList[element] badList[element] = hold print badList …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.