分治算法
天上掉下来个程小白
专业程-小-白
展开
-
快排
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<sys/stat.h> void fastsort(int v[], int first, int last); int main() { int i, v[10] = {1,243,43,5,6,634,434,23,12,7}; fastsort( v, 0, 9); for(i = 0; i < 10; i.原创 2020-12-30 20:55:07 · 125 阅读 · 0 评论 -
Binarysearch
#include<stdio.h> int Binarysearch(int array[],int target,int num){ int counter=0; int first=0; int last=num-1; while(first<=last){ counter++; int mid=(first+last)/2; if(target>array[mid]){ first=mid+1; } else if(target<arr.原创 2020-12-30 20:48:28 · 288 阅读 · 0 评论