modify other_binary_search

This commit is contained in:
koseokkyu 2017-11-20 16:08:47 +09:00
parent 04527dfc56
commit c3bd560d4c

View File

@ -2,15 +2,15 @@
#include <stdlib.h>
#define len 5
int binarySearch(int array[] , int len , int searchX)
{
int binarySearch(int array[], int leng, int searchX)
{
int pos = -1, right, left, i = 0;
left = 0;
right = len - 1;
right = leng - 1;
for(i = 0; i < len ; i++)
for (i = 0; i < leng; i++)
{
pos = (left + right) / 2;
@ -19,10 +19,10 @@ int binarySearch(int array[] , int len , int searchX)
else
{
if (array[pos] < searchX)
right = pos - 1;
left = pos + 1;
else
{
left = pos + 1 ;
right = pos - 1;
}
}
}