《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》
完整开源地址:https://docs.qq.com/doc/DSkNLaERkbnFoS0ZF
14 | int i=0; |
15 | for (i=10;i>=0;i--) |
16 | { |
17 | if (L[i]==key) |
18 | return i; |
19 | } |
20 | return 0; |
21 | } |
22 | int binSearch( int S[11], int key) //折半查找 |
23 | { |
24 | int low=1,high=10,m=0; |
25 | while (low<=high) |
26 | { |
27 | m=(low+high)/2; //折半 |
28 | if (S[m]==key) |
29 | return m; |
30 | if (key<S[m]) |
31 | high=m-1; |
32 | else |
33 | low=m+1; |
34 | } |
35 | return 0; |
36 | } |