Пример метода двоичного поиска Java (двоичный поиск)
复制代码代码如下:public class HalfSearch {public static int halfSearch(int a[], int x) {int middle, left, right;left = 0;right = a.length - 1;mid = (left + right)/ 2; while (a[mid] != x) {if (x > a[mid]) {left = middle + 1;}иначе, если (x <a[mid]) {right =
2024-11-25