(1)qsort:
1 struct STEP 2 { 3 int x; 4 int y; 5 }; 6 7 int cmp(const void *a,const void *b) 8 { 9 STEP step1 = *((STEP *)a); 10 STEP step2 = *((STEP *)b); 11 if(step1.x == step2.x) return step1.y - step2.y; 12 else return step1.x - step2.x; 13 } 14 15 qsort(steps,n,sizeof(STEP),cmp); 16 bsearch(&step,steps,n,sizeof(STEP),cmp);
参考资料:
http://baike.baidu.com/view/982231.htm
http://baike.baidu.com/view/653958.htm
原文:http://www.cnblogs.com/mobileliker/p/3548870.html