望高手写个关于链表里的冒泡排列 不知道如果写
#include<stdio.h>
#include<stdlib.h>
#define N 6
struct code{
    int a;
    struct code *next;
};
int main(void)
{
   struct code *p=NULL,*q,*head=NULL,*t;
   int i,j;
   char flag=1;
   for(i=0;i<N;i++)
   {
      q=(struct code *)malloc(sizeof(struct code));
      scanf("%d",&q->a);
      if(!head)
      head=q;
      else
      p->next=q;
      p=q;
      p->next=NULL;
   }
   
   q=head;
   p=q->next;
   t=q;
   
   for(i=0;i<N-1&&flag==1;i++)
     {
        flag=0;
        for(j=0;j<N-i-1;j++)
        {
            if((q->a)>(p->a))
            {
                if(j==0)
                {
                    q->next=p->next;
                    head=p;
                    p->next=q;
                    
                    t=p;
                    p=q;
                    q=t;
                }
                else
                {
                   q->next=p->next;
                   t->next=p;
                   p->next=q;
                   
                   p=q;
                   q=t->next;
                }
            }
             if(j>0)
                t=t->next;
                q=q->next;
                p=p->next;
                flag=1;
        }
            q=head;
            p=q->next;
            t=q;
     }
   
   for(p=head,i=0;i<N;p=p->next,i++)
    printf("%d",p->a);
}



											
	    

	
