Struct ListNode
{
Int the address;
int data;
Int next;
Struct ListNode * Next;
};
Int main ()
{
Int k;
Struct ListNode * head;
The head=(struct ListNode *) malloc (sizeof (struct ListNode));
The head - & gt; Next=NULL;
Struct ListNode * p, * q;
P=the head;
Int first;
Int number;
int i;
int m;
The scanf (" % d % d % d ", & amp; First, & amp; Number, & amp; M);
Int l=m;
for(i=0; i
Q=(struct ListNode *) malloc (sizeof (struct ListNode));
The scanf (" % d % d % d ", & amp; Q - & gt; Address, & amp; Q - & gt; The data, & amp; Q - & gt; Next);
If (head==NULL)
{
The head=p=q;
}
The else
{
P - & gt; Next=q;
P=q;
}
}
P - & gt; Next=NULL;
P=the head - & gt; Next;
//input the list
//m=4
Head1 struct ListNode * and * temp;
Head1=(struct ListNode *) malloc (sizeof (struct ListNode));
Head1 - & gt; Next=NULL;
Temp=head1;
While (m)
{
If (p - & gt; data=https://bbs.csdn.net/topics/=m)
{
Q=(struct ListNode *) malloc (sizeof (struct ListNode));
Q - & gt; Address=p - & gt; address;
Q - & gt; data=https://bbs.csdn.net/topics/p-> data;
Q - & gt; Next=p - & gt; Next;
If (head1==NULL)
{
Head1=temp=q;
}
The else
{
Temp - & gt; Next=q;
Temp=q;
}
M -;
P=the head - & gt; Next;
}
The else
{
P=p - & gt; Next;
}
}//now within the head1 4 3 2 1
If (number==l)
{
Temp - & gt; Next=NULL;
P=head1 - & gt; Next;
Int a=0;
While (p)
{
If (a==0)
{
Printf (" % 5 d % d ", p - & gt; Address, p - & gt; The data);
}
The else
{
If (p - & gt; Next!=1)
Printf (" % 5 d \ n % 5 d % d ", p - & gt; Address, p - & gt; Address, p - & gt; The data);
The else
{
Printf (" % 5 d \ n % 5 d % d ", p - & gt; Address, p - & gt; Address, p - & gt; The data);
}
}
P=p - & gt; Next;
}
Printf (" 1 ");
}
The else
{
P=the head - & gt; Next;
Int a;
A=l + 1;
While (a<=number)
{
If (p - & gt; data=https://bbs.csdn.net/topics/=a)
{
Q=(struct ListNode *) malloc (sizeof (struct ListNode));
Q - & gt; Address=p - & gt; address;
Q - & gt; data=https://bbs.csdn.net/topics/p-> data;
Q - & gt; Next=p - & gt; Next;
If (head1==NULL)
{
Head1=temp=q;
}
The else
{
Temp - & gt; Next=q;
Temp=q;
}
a++;
P=the head - & gt; Next;
}
The else
{
P=p - & gt; Next;
}
}
//printf (" 1 \ n ");
Temp - & gt; Next=NULL;
//printf (" 3 \ n ");
P=head1 - & gt; Next;
a=0;
While (p)
{
If (a==0)
{
Printf (" % 5 d % d ", p - & gt; Address, p - & gt; The data);
a++;
}
The else
{
If (p - & gt; Next!=1)
Printf (" % 5 d \ n % 5 d % d ", p - & gt; Address, p - & gt; Address, p - & gt; The data);
The else
{
Printf (" % 5 d \ n % 5 d % d ", p - & gt; Address, p - & gt; Address, p - & gt; The data);
}
}
P=p - & gt; Next;
}
Printf (" 1 ");
}
return 0;
}
Test case:
00100 June 4
00000 4 99999
00100 1 12309
68237 6-1
33218 3 00000
99999 5 68237
12309 2 33218
Output right to submit will segment error
CodePudding user response:
Debugging and running down input test cases are no errorsCodePudding user response: