内容纲要
   public static int Find(int value,int[] arrInt) 
        {
            int low = 0;
            int high = arrInt.Length-1;
            int index = -1;

            while (low <= high) 
            {
                int mid = (low + high) / 2;
                if (arrInt[mid] == value)
                {
                    index = mid;
                    return index;
                }
                else if (arrInt[mid] > value)
                {
                    high = mid - 1;
                }
                else 
                {
                    low = mid + 1;
                }
            }
            return index;
        }

1 对 “二分查找法”的想法;

发表评论