
int *binsearch(int x, const int v[], size_t n)
    {
    size_t low = 0;
    size_t high = n;
    int mid;

    while (low < high)
        {
        mid = (low + high) / 2;
        if (x < v[mid])
            high = mid;
        else if (x > v[mid])
            low = mid + 1;
        else
            return &v[mid];
        }
    return 0;
    };



