(1)动态链表排序算法:
struct LOND{
ElemType data;
struct LOND *font;
sttuct LOND *next;
};
typedef LOND struct List;
List *taxis(*head){
int c,t;
c=0;
typedef LOND struct *p;
typedef LOND struct *s;
do{
for(s=head,t=c,p=s->next;s->next=NULL;p=s->next)
{
if(p.data)
{
if(s==head)
{
s->next=p->next;
p->next->font=s;
p->next=s;
p=s->font;
p->font=NULL;
head=p;
}
else
{
s->next=p->next;
p->next->font=s;
p->next=s;
p->font=s->font;
s->font->next=p;
p=s->font;
}
c++;
}
else
{
s=p;
p=p->next;
}
}
}while(c!=t)
}
(2)数组排序算法
int main(int agrc,char *argv[])
{
int a[MAXLINE] = {3,4,1,9,7,0,2,5,8,6};
int i,j,temp;
for (i = 0;i<MAXLINE;i++)
for (j=MAXLINE-1;j>i;j--)
{
if (a[i]>a[j])
{
temp = a[j];
a[j] = a[i];
a[i] = temp;
}
}
for(i=0;i<MAXLINE;i++)
printf("%d/t",a[i]);
return (0);
}
经过测试用10000数,倒序输入然后在通过这个排序正序,用21秒
而SHELL用次方法要用43秒!