提交时间:2023-05-29 21:46:29
运行 ID: 74773
def find(data, n): mid = int(len(data)/2) if len(data) > 1: if data[mid] > n: print('%s in left of %s' %(n, data[mid])) find(data[:mid], n) elif data[mid] < n: print('%s in right of %s' % (n, data[mid])) find(data[mid:], n) else: print('find data') else: print('not in the list') if __name__ == '__main__': data = list(range(1,6000000,7)) find(data, 9098)