清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]; def search(someone, arr): l = - 1 ; h = len(arr); while l + 1 ! = h: m = int((l + h) / 2 ); if arr[m] < someone: l = m; else : h = m; p = h; if p > = len(arr) or arr[p] ! = someone: print ( "元素不存在" ); else : str = "元素位置在第%d位" % p; print (str); |