#include <stdio.h>
#include <math.h
#define compare(x,y) (((x)<(y)) ? -1 : ((X)==(y))?0:1)
int binsearch(int[], int, int, int);
int main(void)
{
int aaa[6] = { 1, 5, 5, 10, 11, 21 };
int binsearch(int list[], int searchnum, int left, int right)
{
The "{" is undelined with the mistake: Error: Expected a “;”
int middle;
while (left <= right)
{
middle = left = (left + right) / 2;
switch (compare(list[middle], searchnum))
{
case -1: left = middle + 1;
break;
case 0:
return middle;
case 1: right = middle - 1;
}
}
return -1;
}
if (binsearch(aaa[], 10, 0, 6) == 10)
{
printf(" %d ", middle);
}
else
{
printf(" %d ", binsearch);
}
return 0;
}
could you help me? what's the problem? that is full-code. i think i missed something but i cannot realize. or is that problem of visual studio2013?