pythonË㷨ʵ¼ù4 ¿ìËÙÅÅÐò
#¿ìËÙÅÅÐò
def Partition(mylist, low, high):
tmp = mylist[low]
while low < high:
while low < high and mylist[high] >= tmp:
high = high - 1
if low < high:
mylist[low] = mylist[high]
low = low + 1
while low < high and mylist[low] <= tmp:
low = low + 1
if low < high:
mylist[high] = mylist[low]
high = high - 1
mylist[low] = tmp
return low
def QuickSort(mylist, low, high):
if low < high:
pivotpos = Partition(mylist, low, high)
QuickSort(mylist, low, pivotpos - 1)
QuickSort(mylist, pivotpos + 1, high)
mylist0 = [11, 10, 3, 12, 33, 1000, 1, 333, -11]
QuickSort(mylist0, 0, len(mylist0) - 1)
print(mylist0)
Ïà¹ØÎĵµ£º
Ò»¡¢Ê¹ÓÃPythonÐèÒªÖªµÀµÄ
ÔÚ Windows ÉÏ£¬°²×° Python ÓÐÁ½ÖÖÑ¡Ôñ¡£
1¡¢ActiveState ÖÆ×÷µÄ ActivePython ÊÇרÃÅÕë¶Ô Windows µÄ Python Ì×¼þ£¬Ëü°üº¬ÁËÒ»¸öÍêÕûµÄ Python ·¢²¼¡¢Ò»¸öÊÊÓÃÓÚPython ±à³ÌµÄ IDE ÒÔ¼°Ò»Ð© PythonµÄ Windows À©Õ¹£¬ÌṩÁËÈ«²¿µÄ·ÃÎÊ Windows APIs µÄ·þÎñ£¬ÒÔ¼° Windows×¢²á±íµÄ×¢²áÐÅÏ¢¡£ËäÈ ......
À´Ô´:
×÷Õß:
Áé½£
1.python ×Ö·û´®Í¨³£Óе¥ÒýºÅ£¨'...'£©¡¢Ë«ÒýºÅ£¨...£©¡¢ÈýÒýºÅ£¨...£©»ò£¨'''...'''£©°üΧ£¬ÈýÒýºÅ°üº¬µÄ×Ö·û´®¿ÉÓɶàÐÐ×é³É£¬Ò»°ã¿É±íʾ´ó¶ÎµÄÐðÊöÐÔ×Ö·û´®¡£ÔÚʹÓÃʱ»ù±¾Ã»Óвî±ð£¬
1.python
×Ö·û´®Í¨³£Óе¥ÒýºÅ£¨'...'£©¡¢Ë«ÒýºÅ£¨"..."£©¡¢ÈýÒýºÅ£¨"""... ......
And last here is the overload operators example:
# map() takes two (or more) arguments, a function and a list to apply the function to
# lambda can be put anywhere a function is expected
# map() calls lambada for every element in the self list
# since Vector has overloaded __getitem__ and __len_ ......
# Ö±½Ó²åÈëÅÅÐò
def InsertSort(mylist):
size = len(mylist)
i = 1
for i in range(1, size):
if mylist[i] < mylist[i - 1]:
tmp = mylist[i]
j = i - 1
mylist[j + 1] = mylist[j]
j = j - 1
while j > ......