_author__ = "Groz"
__data__ = "$2014-6-30 21:58:00$"
if __name__ == "__main__":
print "HELLO"
#define a function
def INSERTION_SORT(A):
for j in range(1,len(A)):
key = A[j]
#Insert A[j] into the sorted sequence A[1..j-1].
i = j - 1
while i >= 0 and A[i] > key:
A[i+1] = A[i]
A[i] = key
i = i - 1
print(A)
def printArr (A):
for j in range(1,len(A)):
print A[j]
x = input("x:")
INSERTION_SORT(x)
插入排序
最新推荐文章于 2024-09-28 15:39:21 发布