小迪的Blog
学习ing...(注明:该Blog中的任何信息都非原创,只是作为个人的阅读笔记)
void QuickSort(SeqList R,int low,int high)

    
// 对R[low..high]快速排序
    int pivotPos;    // 划分后的基准记录的位置
    if(low < high)
    
{
        
// 仅当区间长度大于1时才须排序
        pivotPos = Partition(R,low,high); // 对R[low..high]做划分
        QuickSort(R,low,pivotPos - 1); // 对左区间递归排序
        QuickSort(R,pivotPos + 1,high); // 对右区间递归排序
    }

}
 // QuickSort

void QuickSort(int[] x, int s, int t)
{
    
int temp;
    
int i = s, j = t;
    
if(s < t)
    
{
        temp 
= x[s];
        
do
        
{
            
while(j > i && x[j] >= temp)
            
{
                j
--;
            }

            
if(i < j)
            
{
                x[i] 
= x[j];
                i
++;

            }

            
while(i < j && x[i] <= temp)
            
{
                i
++;
            }

            
if(i < j)
            
{
                x[j] 
= x[i];
                j
--;
            }

        }
while(i < j);
        x[i] 
= temp;
        QuickSort(x,s,j
-1);
        QuickSort(x,j
+1,t);

    }

}
posted on 2005-12-13 19:44  小迪  阅读(459)  评论(0编辑  收藏  举报