程设小组作业——计算机配件的进货/销售管理系统

sort.h 对链表按照时间排序

/////////////////////////
 /*
     排序函数:将链表按时间排序 
 */ 
 plink sort(plink head){
     plink p,p0,r,r0,q;
     p0=NULL;
     p=head;
     while(p!=NULL){
         r=head;
         while((r->ll_timell_time)&&(r!=p)){
             r0=r;
             r=r->next;
         }
     if(r!=p)
     {         
         q=p;         
         p0->next=p->next;         
         p=p0;         
         if(r==head)
         {             
             q->next=head;             
             head=q;         
         }         
         else
         {             
             q->next=r;             
             r0->next=q;         
         }     
     }     
     p0=p;     
     p=p->next; 
    } 
     return head;
 }

点赞

发表评论