W3Schools Tryit Editor
[
フレーム
]
Run ❯
Get your
own Python
server
Go to Spaces
Ctrl+Alt+P
def binarySearch(arr, targetVal): left = 0 right = len(arr) - 1 while left <= right: mid = (left + right) // 2 if arr[mid] == targetVal: return mid if arr[mid] < targetVal: left = mid + 1 else: right = mid - 1 return -1 mylist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19] x = 11 result = binarySearch(mylist, x) if result != -1: print("Found at index", result) else: print("Not found")
Found at index 5
AltStyle
によって変換されたページ
(->オリジナル)
/
アドレス:
モード:
デフォルト
音声ブラウザ
ルビ付き
配色反転
文字拡大
モバイル