69,381
社区成员
发帖
与我相关
我的任务
分享
typedef struct Node{
int data;
struct Node *next;
}* List , Node;
void sort(List *list) /* Selection Sort */
{
Node *h, *t, *s, *tail, *u, *v;
h = (*list);
s = NULL;
while(h){
for(t=u=h; !u->next; u=u->next)
if(u->next->data < t->data)
{
v = u;
t = u->next;
}
if(t==h)
{
h = h-> next;
}
else
{
v->next = t->next;
}
if(!s)
{
tail=s=t;
}
else
{
tail = tail->next = t;
}
}
if(s) tail->next = NULL;
*list=s;
}