| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 556 人关注过本帖
标题:[求助]快速排序,小弟的程序有问题
只看楼主 加入收藏
java在线
Rank: 1
等 级:新手上路
帖 子:93
专家分:0
注 册:2005-7-9
结帖率:100%
收藏
 问题点数:0 回复次数:0 
[求助]快速排序,小弟的程序有问题

#include "stdio.h"
struct number
{
int num;
struct number *pri;
struct number *next;
};
main()
{
struct number *create(void);
void Qsort(int*,int*);
void list(struct number*);
}
struct number *create(void)
{
struct number *low,*high,*p1;
low=high=0;
printf("please input a number\n");
printf("input 0 to end");
p1=(struct number*)malloc(sizeof(struct number));
scanf("%d",&p1->num);
while(p1->num!=0)
{
if(low==0) { low=p1; p1->pri=0; }
else high->next=p1;
high=p1;
p1=(struct number*)malloc(sizeof(struct number));
scanf("%d",p1->num);
p1->pri=high;
}
high->next=0;
free(p1);
return low;
}
void Qsort(int* low,int* high)
{
struct number *pivotloc;
struct number *partition(int*,int*);
if(low!=high)
{
pivotloc=partition(low,high);
Qsort(low,pivotloc->pri);
Qsort(pivotloc->next,high);
}
}
struct number* partition(int* low,int* high)
{
int r;
struct number *pl,*ph;
pl=low;
ph=high;
r=pl->num;
while(low!=high)
{
while(pl!=ph&&ph->num>=r) ph=ph->pri;
pl->num=ph->num;
while(pl!=ph&&pl->num<=r) pl=pl->next;
ph->num=pl->num;
}
pl->num=r;
return pl;
}
void list (struct number *p)
{
printf("The linked list:\n");
while(p!=0)
{
printf("%d\n",p->num);
p=p->next;
}
}

搜索更多相关主题的帖子: include please number create 
2006-02-20 10:05
快速回复:[求助]快速排序,小弟的程序有问题
数据加载中...
 
   



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

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