原创 单链表的排序

2010-6-24 20:46 1994 7 7 分类: MCU/ 嵌入式
单链表的排序



typedef struct node
{
        int data;
        struct node *next;
}Node;

void sort(Node *head)
{
        Node *p, *q, *r;
        int temp;

        for(p=head->next;p->next!=NULL;p=p->next)
        {
                r="p";
                for(q=p->next;q!=NULL;q=q->next)
                        if(q->data <= r->data)
                                r="q";
                if(r!=p)
                {
                        temp="p-">data;
                        p->data=r->data;
                        r->data=temp;
                }
        }
}
PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
我要评论
0
7
关闭 站长推荐上一条 /1 下一条