qsort6.c

来自「自己做的常用库和实现的数据结构。public domain.」· C语言 代码 · 共 36 行

C
36
字号
void   quicksort(int   v[],   int   low,   int   high)    {            int   lowIndex[MAXSIZE],   highIndex[MAXSIZE];                int   n;                int   last;            int   currentLow,   currentHigh;            int   i;                       n   =   1;            lowIndex[n]   =   low;            highIndex[n]   =   high;            while   (n   >   0)   {                    currentLow   =   lowIndex[n];                    currentHigh   =   highIndex[n];                    --n;                                       if   (currentLow   >=   currentHigh)                            continue;                                                                                   last   =   currentLow;                    for   (i   =   currentLow   +   1;   i   <=   currentHigh;   ++i)   {                            if   (v[i]   <   v[currentLow])   {                                    ++last;                                    swap(v,   last,   i);                            }                    }                    swap(v,   currentLow,   last);                    ++n;                    lowIndex[n]   =   last   +   1;                    highIndex[n]   =   currentHigh;                    ++n;                    lowIndex[n]   =   currentLow;                    highIndex[n]   =   last   -   1;            }    

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?