标题:快速排序问题解决不了
取消只看楼主
cwl168
Rank: 1
等 级:新手上路
帖 子:48
专家分:0
注 册:2012-12-14
结帖率:8.33%
已结贴  问题点数:10 回复次数:1 
快速排序问题解决不了
#define SIZE 100
#include <stdio.h>
#include <malloc.h>
typedef struct{
    int key;
    int nexi;
}SLNode;
typedef struct{
    SLNode r[SIZE];
    int length;
    struct SqList *next;
}SqList ,*LinkList;

LinkList CreateList_L(LinkList&L,int n){
        int i;
        LinkList p;
    L=(LinkList)malloc(sizeof(SqList));
        L->next=NULL;
        for(i=n;i>0;--i){
                p=(LinkList)malloc(sizeof(SqList));
                p->next=null;
                p->data=getchar();
                p->next=L->next;
                L->next=p;
        }
        return L;
}

int Partition(SqList &L, int low, int high){
    int pivotkey;
   L.r[0] = L.r[low];
   pivotkey = L.r[low].key;
   while (low<high) {
      while (low<high && L.r[high].key>=pivotkey)
       --high;
       L.r[low] = L.r[high];
       while (low<high && L.r[low].key<=pivotkey)
       ++low;
        L.r[high] = L.r[low];
   }
   L.r[low] = L.r[0];            
   return low;                  
}
void QSort(SqList &L, int low, int high)
 {  int pivotloc;
     if (low < high)
         {
           pivotloc = Partition(L, low, high);
           
           QSort(L, low, pivotloc-1);
         
           QSort(L, pivotloc+1, high);
           
  }
}
main(){
    LinkList L;
    L=CreateList_L(L,10);
    QSort(L, 1,10);
}
   



搜索更多相关主题的帖子: next include null 
2013-01-02 20:39
cwl168
Rank: 1
等 级:新手上路
帖 子:48
专家分:0
注 册:2012-12-14
得分:0 
你真菜
2013-01-03 19:57



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-394855-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.127385 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved