折半查找
摘要:
折半查找的前提是有序的,与中间值进行比较,如果有序的则返回;否则,改变始末位置,再进行查找实现方法:1 循环实现 2 递归实现1 循环实现#include<stdio.h>int binary_search(int *array,int n,int data);int main(){int array[10]={1,2,3,4,5,6,7,8,9,10};printf("please input the number that you want search\n");int num;scanf("%d",&num);int resul 阅读全文
posted @ 2012-05-09 19:09 ITfeng 阅读(181) 评论(0) 推荐(0) 编辑