mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-11-28 15:06:38 +08:00
formatting source-code for d7af6fdc8c
This commit is contained in:
@@ -12,10 +12,12 @@
|
||||
* \returns index if T is found
|
||||
* \return -1 if T is not found
|
||||
*/
|
||||
int binary_search(int a[], int r, int key) {
|
||||
int binary_search(int a[], int r, int key)
|
||||
{
|
||||
int l = 0;
|
||||
|
||||
while (l <= r) {
|
||||
while (l <= r)
|
||||
{
|
||||
int m = l + (r - l) / 2;
|
||||
if (key == a[m])
|
||||
return m;
|
||||
@@ -28,7 +30,8 @@ int binary_search(int a[], int r, int key) {
|
||||
}
|
||||
|
||||
/** main function */
|
||||
int main(int argc, char const* argv[]) {
|
||||
int main(int argc, char const* argv[])
|
||||
{
|
||||
int n, key;
|
||||
std::cout << "Enter size of array: ";
|
||||
std::cin >> n;
|
||||
@@ -37,7 +40,8 @@ int main(int argc, char const* argv[]) {
|
||||
int* a = new int[n];
|
||||
|
||||
// this loop use for store value in Array
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
std::cin >> a[i];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user