求兩個單鏈表的差

nodetype *minus(nodetype *h1,nodetype *h2)
{
 nodetype *p,*q;
 p=h1->next;
 q=h2->next;
 if(p==NULL)
  return h2;
 if(q==NULL)
  return h1;
 while(q!=NULL)
 {
  p=h1->next;
  int i=1;
  while(p!=NULL)
  {
   if(p->data!=q->data)
   {
    p=p->next;
    i++;
   }
   else
   {
    h1=del(h1,i);
    p=NULL;
   }
  }
  q=q->next;
 }
 return h1;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章