mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
Update Binary Search.cpp
This commit is contained in:
parent
9543e522f2
commit
dd09663ece
@ -11,7 +11,7 @@ l = m + 1;
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int main(int argc, char const *argv[]) {
|
int main() {
|
||||||
int n, key;
|
int n, key;
|
||||||
std::cout << "Enter size of array: ";
|
std::cout << "Enter size of array: ";
|
||||||
std::cin >> n;
|
std::cin >> n;
|
||||||
@ -24,7 +24,7 @@ std::cout << "Enter search key: ";
|
|||||||
std::cin >> key;
|
std::cin >> key;
|
||||||
int res = binary_search(a, 0, n - 1, key);
|
int res = binary_search(a, 0, n - 1, key);
|
||||||
if (res != -1)
|
if (res != -1)
|
||||||
std::cout << key << " found at index " << res << endl;
|
std::cout << key << " found at index " << res << std::endl;
|
||||||
else
|
else
|
||||||
std::cout << key << " not found" << endl;
|
std::cout << key << " not found" << endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user