import random
def randPrint(shuzu, low, high):
if low == high:
print(shuzu[low])
else:
middle = random.randint(low, high)
if middle == low:
print(shuzu[middle])
randPrint(shuzu,middle+1,high)
elif middle == high:
print(shuzu[middle])
randPrint(shuzu, low, high-1)
else:
print(shuzu[middle])
randPrint(shuzu, low, middle - 1)
randPrint(shuzu, middle+1, high)
a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
randPrint(a, 0, 9)
转载于:https://my.oschina.net/stevenKelly/blog/389313