把这段代码从python转换为javascript: def find(arr, x, start, end): if start > end: return False mid = (start + end) // 2 if arr[mid] == x: return True if arr[mid] > x: return find(arr, x, start, mid - 1) else: return find(arr, x, mid + 1, end)
时间: 2023-05-31 19:04:03 浏览: 184
vcv.rar_bmp to arr_bmp 数组_site:www.pudn.com
function find(arr, x, start, end) {
if (start > end) {
return false;
}
var mid = Math.floor((start + end) / 2);
if (arr[mid] == x) {
return true;
}
if (arr[mid] > x) {
return find(arr, x, start, mid - 1);
} else {
return find(arr, x, mid + 1, end);
}
}
阅读全文