时光飞逝~

2013年7月13日

二分查找

摘要: 1 //算法 2 //1 找中值 3 //2 将要找的数和中值进行比较, 4 // 如果大于中值,则从右边的序列找,调用递归 5 // 如果要找的数小于中值,则从左边的序列找,调用递归 6 // 如果相等,找到 7 // 如果没找到,返回-1 8 9 #include "stdio.h"10 //二分查找11 int BinaryFind(int *a, int nLen,int data)12 {13 int nLeft = 0;14 int nRight = nLen-1;15 int mid = (nLeft+nRight)/2;16 ... 阅读全文

posted @ 2013-07-13 21:50 时光飞逝~ 阅读(128) 评论(0) 推荐(0)