易截截图软件、单文件、免安装、纯绿色、仅160KB

python算法实践2 shell排序

#shell排序
def ShellPass(mylist, d):
size = len(mylist)
i = d
while i < size:
if mylist[i] < mylist[i - d]:
tmp = mylist[i]
j = i - d
mylist[j + d] = mylist[j]
j = j - d
while j >= 0 and mylist[j] > tmp:
mylist[j + d] = mylist[j]
j = j - d
mylist[j + d] = tmp
i = i + d
def ShellSort(mylist):
n = len(mylist)
while n > 1:
n = n // 3 + 1
ShellPass(mylist, n)

mylist0 = [12, 11, 13, 1, 2, 4, 3, 77, 44]
ShellSort(mylist0)
print(mylist0)
 


相关文档:

Python int类型插入数据库 MySQLdb

 def test2():
 32     db = util.DBUnit('mysql_ab')                                    &nb ......

python字符串使用总结



来源:
作者:
灵剑
1.python 字符串通常有单引号('...')、双引号(...)、三引号(...)或('''...''')包围,三引号包含的字符串可由多行组成,一般可表示大段的叙述性字符串。在使用时基本没有差别,

1.python
字符串通常有单引号('...')、双引号("...")、三引号("""... ......

python类型转换、数值操作


2008-12-21
python类型转换、数值操作
关键字: python类型转换、数值操作
python类型转换
Java代码
函数                      描述   
int(x [,base ])    ......

example of python operator overloadind

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_ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号