算法

 char* str_cpy(char* dest,char*src){

if(dest ==NULL|| src ==NULL) {

returnNULL;

}

char*strdest = dest;

char*strSrc = src;

while( (*strdest++ = *strSrc++) !='\0');

returnstrdest;

}

void* mem_cpy(void*dest,void*src,size_tsize){

if(dest ==NULL|| src ==NULL)

returnNULL;

char* temp_des = (char*)dest;

char* temp_src = (char*)src;

while( size-- >0) {

*temp_des++ = *temp_src++;

}

returntemp_des;

}

-(void)insertSort{

intx[] = {4,3,7,8,45,3,5,2,99,1};

for(inti=1; i

for(intj = i; j>0&& x[j-1]>x[j];j--) {

inttemp = x[j];

x[j]=x[j-1];

x[j-1] = temp;

}

}

for(inti =0; i

printf(" %d",x[i]);

}

}

voidquick_sort(int* s,intl,intr)

{

if(l < r)

{

/*

72 6 57 88 60 42 83 73 48 85

*/

//Swap(s[l], s[(l + r) / 2]); //将中间的这个数和第一个数交换参见注1

inti = l, j = r, t = s[l];

while(i < j)

{

while(i < j && s[j] >= t)//从右向左找第一个小于t的数

j--;

if(i < j)

s[i++] = s[j];

while(i < j && s[i] < t)//从左向右找第一个大于等于t的数

i++;

if(i < j)

s[j--] = s[i];

}

s[i] = t;

quickSort(s, l, i -1);//递归调用

quickSort(s, i +1, r);

}

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容