When I run check50 it states that helpers.c doesn't compile, but it finds the numbers correctly in the arrays. I'm lost. Any help is appreciated.
~/workspace/pset3/find/ $ check50 2015.fall.pset3.find helpers.c
:) helpers.c exists
:( helpers.c compiles
\ expected an exit code of 0, not standard error of "/tmp/find-9VOFcu.o: In function `main':..."
:| finds 42 in {42,43,44}
\ can't check until a frown turns upside down
:| finds 42 in {41,42,43}
\ can't check until a frown turns upside down
:| finds 42 in {40,41,42}
\ can't check until a frown turns upside down
:| finds 42 in {41,42,43,44}
\ can't check until a frown turns upside down
:| finds 42 in {40,41,42,43}
\ can't check until a frown turns upside down
:| finds 42 in {39,40,41,42}
\ can't check until a frown turns upside down
:| doesn't find 42 in {39,40,41}
\ can't check until a frown turns upside down
:| doesn't find 42 in {39,40,41,43}
\ can't check until a frown turns upside down
Here is my helper.c file.
bool BinarySearch(int value, int values[], int n)
{
int min = 0;
int max = n - 1;
while (max >= min)
{
int mid = (max + min)/2;
if (values[mid] == value)
{
return true;
}
if (values[mid] > value)
{
max = mid - 1;
}
else if (values[mid] < value)
{
min = mid + 1;
}
}
return false;
}
void sort(int values[], int n)
{
int i, j, h, min;
for (i = 0; i < n - 1; i++)
{
min = i;
for (j = i + 1; j < n; j++)
{
if (values[j] < values[min])
{
min = j;
}
}
if (min != 1)
{
h = values[i];
values[i] = values[min];
values[min] = h;
}
}
return;
}