标签:static sea while arc 查找 bin int TE binary
/* 折半查找 */ /* 输出:9 */ static int BinarySearch(int [] a, int n, int key){ int low, high, mid; low = 0; high = n; while(low <= high){ mid = (low + high) / 2; /* 折半 */ if (key < a[mid]){ high = mid - 1; } else if (key > a[mid]){ low = mid + 1; } else return mid; } return 0; }
标签:static sea while arc 查找 bin int TE binary
原文地址:https://www.cnblogs.com/CHWLearningNotes/p/9158924.html