2007年7月2日星期一

qsort

qsort 使用 qsort 函数是ANSI C标准中提供的,其声明在stdlib.h文件中,具体内容为: void qsort(void *base, size_t nelem, size_t width, int (*fcmp)(const void *, const void *)); 其中: * base    为要排序的数组 nelem    为要排序数组的长度 width      为数组元素的大小(以字节为单位) (*fcmp)(const void * a, const void * b)    为判断大小函数的指针,这个函数需要程序员自己定义, 如果a>b,函数返回1a<b,函数返回-1a=b,函数返回0 例:字符串排序 i nclude <stdio.h>  i nclude <stdlib.h>  i nclude <string.h>  char list[5][4]={"cat","car","cab","cap","can" };  i

 

2 条评论:

匿名 说...

Gostei muito desse post e seu blog é muito interessante, vou passar por aqui sempre =) Depois dá uma passada lá no meu site, que é sobre o CresceNet, espero que goste. O endereço dele é http://www.provedorcrescenet.com . Um abraço.

匿名 说...

Hello. This post is likeable, and your blog is very interesting, congratulations :-). I will add in my blogroll =). If possible gives a last there on my blog, it is about the TV Digital, I hope you enjoy. The address is http://tv-digital-brasil.blogspot.com. A hug.