书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

2011年10月13日

二分查找

摘要: 这个是精简了的二分查找,个人觉得实在是无法简化了,如果还可以的话,请高人指点一二,先谢谢了。View Code #include "iostream"#include "algorithm"using namespace std;int BinSearch(int *R, int n, int KeyNum){ int low = 0, high = n+1, mid=0; //mid设置为0,是为了利用R[mid]来查找,这样更加精简代码 while(low <= high) { if(R[mid] == KeyNum) //包含了R[0]的情况 阅读全文

posted @ 2011-10-13 22:53 More study needed. 阅读(215) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

点击右上角即可分享
微信分享提示