[C] 快速排序 →→→→→进入此内容的聊天室

来自 , 2020-09-23, 写在 C, 查看 154 次.
URL http://www.code666.cn/view/f6e794a7
  1. int Partition ( S_TBL *tbl,int low,int high ) /*一趟快排序*/
  2. { /*交换顺序表tbl 中子表tbl->[low…high]的记录,使支点记录到位,并反回其所在位置*/
  3.         /*此时,在它之前(后)的记录均不大(小)于它*/
  4.         tbl->r[0]=tbl->r[low]; /*以子表的第一个记录作为支点记录*/
  5.         pivotkey=tbl->r[low].key; /*取支点记录关键码*/
  6.         while ( low<higu ) /*从表的两端交替地向中间扫描*/
  7.         {
  8.                 while ( low<high&&tbl->r[high].key>=pivotkey ) high--;
  9.                 tbl->r[low]=tbl->r[high]; /*将比支点记录小的交换到低端*/
  10.                 while ( low<high&&tbl-g>r[high].key<=pivotkey ) low++;
  11.                 tbl->r[low]=tbl->r[high]; /*将比支点记录大的交换到低端*/
  12.         }
  13.         tbl->r[low]=tbl->r[0]; /*支点记录到位*/
  14.         return low; /*反回支点记录所在位置*/
  15. }
  16.  

回复 "快速排序"

这儿你可以回复上面这条便签

captcha