Polish some cotents.

This commit is contained in:
krahets
2023-05-18 20:27:58 +08:00
parent 335bc29af2
commit 399e5df39a
16 changed files with 39 additions and 37 deletions

View File

@@ -25,7 +25,7 @@ int binarySearch(int *nums, int len, int target) {
}
/* 二分查找(左闭右开) */
int binarySearch1(int *nums, int len, int target) {
int binarySearchLCRO(int *nums, int len, int target) {
// 初始化左闭右开 [0, n) ,即 i, j 分别指向数组首元素、尾元素+1
int i = 0, j = len;
// 循环,当搜索区间为空时跳出(当 i = j 时为空)
@@ -52,7 +52,7 @@ int main() {
printf("目标元素 6 的索引 = %d\n", index);
/* 二分查找(左闭右开) */
index = binarySearch1(nums, 10, target);
index = binarySearchLCRO(nums, 10, target);
printf("目标元素 6 的索引 = %d\n", index);
return 0;