pythonË㷨ʵ¼ù7 ¹é²¢ÅÅÐò
def MergeSort(mylist, low, mid, high):
i = low
j = mid + 1
tmp = []
while i <= mid and j <= high:
if mylist[i] <= mylist[j]:
tmp.append(mylist[i])
i = i + 1
else:
tmp.append(mylist[j])
j = j + 1
while i <= mid:
tmp.append(mylist[i])
i = i + 1
while j <= high:
tmp.append(mylist[j])
j = j + 1
for k in range(low, high):
mylist[k] = tmp[k]
mylist0 = [1, 3, 5, 7, 9, 11, 6, 8, 66, 88, 100]
MergeSort(mylist0, 0, 5, len(mylist0) - 1)
print(mylist0)
Ïà¹ØÎĵµ£º
Programming Python, 2nd Edition (O'Reilly)
http://www.osbbs.com/dl/Programming Python, 2nd Edition (O'Reilly).chm
ºÜÈ«ºÜ¾µäÁËpythonѧϰÈëÃÅ×ÊÁÏ
OReilly - Learning Python:
http://www.osbbs.com/dl/OReilly - Learning Python.chm
......
PythonµÄÄÚ´æй©¼°gcÄ£¿éµÄʹÓÃ
-- 6.11ÈÕ´íÎóÐÞÕý°æ
Horin|ºØÇÚ
Email: horin153@msn.com
......
Öð²½Ñݽø
f=open('/etc/motd','r')
longest=0
while True:
lineLen=len(f.readline().strip())
if not lineLen: break
if lineLen > longest:
longest=lineLen
f.close()
return longest
ÎÊÌâ£ºÒ»Ö±Õ¼Ó ......
Ref : http://www.swig.org/translations/chinese/tutorial.html
¼ÙÉèÄãÓÐһЩcÄãÏëÔÙ¼ÓPython.¡£¾ÙÀýÀ´ËµÓÐÕâôһ¸öÎļþexample.c
/* File : example.c */
#include <time.h>
double My_variable = 3.0;
int fact(int n) {
if (n <= 1) return 1;
&nbs ......
±³¾°
ÏîÄ¿µÄ
×Ô¶¯»¯²âÊÔÖÐÒѾʹÓÃÁË»ùÓÚPython
½Å±¾µÄ¿ò¼Ü£¬×Ô¶¯»¯¹ý³ÌÖÐ×î¹Ø¼üµÄÎÊÌâ¾ÍÊÇÈçºÎʵÏÖ׮ģ¿é¡£ÔËÓÃ
Python
Ç¿´óµÄ¹¦ÄÜ£¬ÊµÏÖÈκÎ׮ģ¿é¶¼ÊÇ¿ÉÄܵģ¬µ«ÊÇÊÇ·ñ±ØÐëÍêȫʹÓÃ
Python
ʵÏÖÄ£¿éÂß¼£¬³É±¾ÊÇÒ»¸ö¾ö¶¨ÐÔÒòËØ¡£ÔÚ׮ģ¿éÂß¼¼òµ¥µÄÇé¿öÏ£¬Ê¹ÓÃ
Python
Ä£ÄâÄ£¿éÂß¼²»µ«Ê¹×Ô¶¯»¯²âÊԵĽṹÇå ......