int search(vector<int>& nums, int target) {
     if (nums.size() == 0) return -1;
     int start = 0;
     int end = nums.size() - 1;
     if (target < nums[start] && target > nums[end]) return -1;
     int min = findMin(nums);
     if (target >= nums[start]) {
         if (min == start) {
             return BiSearch(nums, start, end, target);
         } else {
             return BiSearch(nums, start, min - 1, target);
         } 
     }
     if (target <= nums[end]) {
         return BiSearch(nums, min, end, target);
     }         
 }
Ejemplo n.º 2
0
void countKeyWords(char* word, SeqWords* SW)
{
	if(!isKeyWords(word))
		return;
	int index = BiSearch(word, KeyWords, 0, TOTAL-1, bi_cmp_count);	
	if(index >= 0)
		SW[index].count++;
}