标签:查找 div style color rgb col else code ==
1 //折半查找 2 #include<iostream> 3 #include <algorithm> 4 using namespace std; 5 int zheban(int a[], int n, int k) 6 { 7 int low = 1, high = n - 1, mid; 8 while (low<=high) 9 { 10 mid = (low + high) / 2; 11 if (k==a[mid]) 12 { 13 return mid; 14 } 15 if (k<a[mid]) 16 { 17 high = mid - 1; 18 } 19 else 20 { 21 low = mid + 1; 22 } 23 } 24 return 0; 25 } 26 int main() 27 { 28 int a[6] = { 5,2,4,3,7,0 }; 29 sort(a,a+6); 30 for (auto x : a) 31 { 32 cout << x << " "; 33 } 34 cout << endl; 35 cout << zheban(a, 6, 2); 36 return 0; 37 }
标签:查找 div style color rgb col else code ==
原文地址:https://www.cnblogs.com/dss-99/p/14141765.html