Home > Back-end >  C check list for intersection wrong for help
C check list for intersection wrong for help

Time:09-25

Node * mix (* head1 Node, the Node * head2)
{
Head=NULL Node * and * p1=head1, * p2=head2;
for (; P1!=NULL; P1=p1 - & gt; Next)
for (; The p2!=NULL; The p2=p2 - & gt; Next)
{
Node * p3=new Node;
If (p1 - & gt; The content==p2 - & gt; The content)
{
P3 - & gt; The content=p1 - & gt; The content;
P3 - & gt; Next=head;
The head=p3;
}
}
Return the head;
}

CodePudding user response:

C + + intersection with the list, is the program I wrote above, but the output is wrong, beg god taught!

CodePudding user response:

You in the first two for loop outside the definition and initialize the third list, and then try again within a for loop assignment

CodePudding user response:

 I'm sorry, can't understand, I define the head, not on the outside of the for loop initialization third list?
  • Related