03 2014 档案

摘要:七种qsort排序方法一、对int类型数组排序int num[100];Sample:int cmp ( const void *a , const void *b ){return *(int *)a - *(int *)b;}qsort(num,100,sizeof(num[0]),cmp);二、对char类型数组排序(同int类型)char word[100];Sample:int cmp( const void *a , const void *b ){return *(char *)a - *(int *)b;}qsort(word,100,sizeof(word[0]),cmp); 阅读全文
posted @ 2014-03-07 20:17 心中的阿哲 阅读(255) 评论(0) 推荐(0)
摘要:1 #include 2 struct group{ 3 4 int value; 5 int weight; 6 7 }; 8 void Sort(group bag[],int num) 9 {10 int i,j;11 group temp;12 for(i=1; ibag[j].value)15 {16 temp=bag[j];17 bag[j]=bag[j+1];18 bag[j+1]=temp;19 ... 阅读全文
posted @ 2014-03-03 22:10 心中的阿哲 阅读(133) 评论(0) 推荐(0)