文章出處

排序算法:https://zh.wikipedia.org/wiki/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95

搜尋算法-二分搜索法(折半查找):https://zh.wikipedia.org/wiki/%E4%BA%8C%E5%88%86%E6%90%9C%E7%B4%A2%E7%AE%97%E6%B3%95

    static int SeachBinary(int[] arrs, int start, int end, int key)
    {
        if (start > end)
        {
            return -1;
        }
        int mid = start + (end - start) / 2;
        if (arrs[mid] > key)
        {
            return SeachBinary(arrs, start, mid - 1, key);
        }

        if (arrs[mid] < key)
        {
            return SeachBinary(arrs, mid + 1, end, key);
        }
        return mid;
    }

文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()