進行二分查找有四個步驟:
第一步:while(start+1<end) //之所以需要這麼寫,是可能在後面使用到這兩個位置,比如leetcode上需要找11223344,裏面的2元素,start和end就可以返回這兩個位置。
第二步:mid=start+(end-start)/2
第三步:==,>,<;
進行二分查找有四個步驟:
第一步:while(start+1<end) //之所以需要這麼寫,是可能在後面使用到這兩個位置,比如leetcode上需要找11223344,裏面的2元素,start和end就可以返回這兩個位置。
第二步:mid=start+(end-start)/2
第三步:==,>,<;
unsigned int MAX = 32; // 2的5次方 unsigned int index = 31; index = (index + 100) % MAX; printf ("inde