文章出處
文章列表
排序算法: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;
}
文章列表
全站熱搜