Example #1
0
//二分查找
void binaryFind(int a[], int s, int e, int x){
    if (s >= e) return ;
    int middle = (s + e)/2;
    if (a[middle] == x){
        printf("find it : %d \n",middle);
        return;
    }else if(a[middle] > x){
        binaryFind(a,s,middle,x);
    }else if(a[middle] < x){
        binaryFind(a,middle + 1,e,x);
    }
}
Example #2
0
char LTable_Reverse(LTable* lt, const char* hash, char* dst)
{
	s32 res = binaryFind(lt, hash);
	if (res < 0)
		return 0;

	memcpy(dst, CSTR(res), lt->l_string);
	return 1;
}