tail=p和tail->next=p有什么区别呀?
出现在C++链表里的知识,一直没弄明白。。。
求交集:
Node *jiao(Node *h1,Node *h2)
Node *p1=h1,*p2=h2,*head=NULL,*tail;
while(p1!=NULL)&&(p2!=NULL)
{
if(p1->content==p2->content)
{
Node *q=new Node;
q->content=p2->content;
q->next=NULL;
if(head==NULL)
head=q;
else
tail->next=q;
tail=q;}
else if(p1->content<p2->content)
p1=p1->next;
else
p2=p2->next;
}
return head;
}