# include & lt; stdio.h>
#include
Typedef struct Node {
Int adress.
The int data;
Int nextadress;
Struct Node * Next;
} the Node;
Typedef struct Node * List;
Int main () {
The List L1, L, p, q;
Int fadress, k, n.
The scanf (" % d % d % d ", & amp; Fadress, & amp; N, & amp; k);
int i;
L1=(List) malloc (sizeof (Node));
L1 - & gt; Next=NULL;
Q=L1.
for(i=0; iP=(List) malloc (sizeof (Node));
The scanf (" % d % d % d ", & amp; P - & gt; Adress, & amp; P - & gt; The data, & amp; P - & gt; Nextadress);
Q - & gt; Next=p;
Q=p;
}
Q - & gt; Next=NULL;
/* the List t;
T=L1 - & gt; Next;
While (t) {
If (t - & gt; Next) {
05 05 printf (" % d % d % d \ n ", t - & gt; Adress, t - & gt; The data, t - & gt; Nextadress);
} else {
Printf (" % 5 d % d % d \ n ", t - & gt; Adress, t - & gt; The data, t - & gt; Nextadress);
}
T=t - & gt; Next;
}
printf("\n"); */
The List newL newp, newq, t;
NewL=(List) malloc (sizeof (Node));
NewL - & gt; Next=NULL;
Newq=newL;
T=L1 - & gt; Next;
For (I=k; I>=1; I -) {
While (t) {
If (t - & gt; data=https://bbs.csdn.net/topics/=i) {
Newp=(List) malloc (sizeof (Node));
Newp - & gt; Adress=t - & gt; Adress.
Newp - & gt; data=https://bbs.csdn.net/topics/t-> data;
Newp - & gt; Nextadress=t - & gt; Nextadress;
Newq - & gt; Next=newp;
Newq=newp;
break;
} else {
T=t - & gt; Next;
}
}
T=L1 - & gt; Next;
}
For (I=k + 1; i<=n; I++) {
T=L1 - & gt; Next;
While (t) {
If (t - & gt; data=https://bbs.csdn.net/topics/=i) {
Newp=(List) malloc (sizeof (Node));
Newp - & gt; Adress=t - & gt; Adress.
Newp - & gt; data=https://bbs.csdn.net/topics/t-> data;
Newp - & gt; Nextadress=t - & gt; Nextadress;
Newq - & gt; Next=newp;
Newq=newp;
break;
} else {
T=t - & gt; Next;
}
}
}
Newq - & gt; Next=NULL;
List the L2, x1, x2,
X1=newL - & gt; Next;
X2=x1 - & gt; Next;
L2=newL;
for(i=0; iIf (x2 - & gt; Next) {
X1 - & gt; Nextadress=x2 - & gt; Adress.
L2 - & gt; Next=x1;
L2=x1;
X1=x1 - & gt; Next;
X2=x2 - & gt; Next;
}
}
X1 - & gt; Nextadress=x2 - & gt; Adress.
L2 - & gt; Next=x1;
L2=x1;
X1=x1 - & gt; Next;
L2 - & gt; Next=x1;
L2=x1;
L2 - & gt; Next=NULL;
The List f;
F=newL - & gt; Next;
While (f) {
If (f - & gt; Next) {
05 05 printf (" % d % d % d \ n ", f - & gt; Adress, f - & gt; The data, the f - & gt; Nextadress);
} else {
Printf (" % 5 d % d % d \ n ", f - & gt; Adress, f - & gt; The data, the f - & gt; Nextadress);
}
F=f - & gt; Next;
}
return 0;
}
I run on their own ide the answer with the same case as soon as you submit prompt segmentation fault... Small white for guiding
This is the result of I run the compiler
A case of topic request
CodePudding user response:
Seek bosses advice QAQCodePudding user response:
CodePudding user response:
Said the demandCodePudding user response:
List the L2, x1, x2,X1=newL - & gt; Next;
X2=x1 - & gt; Next;
L2=newL;
for(i=0; i
80 lines before and after this period, you can ensure newL of at least two elements?
If there is only one element, x2=x1 - & gt; Next, the x2 is NULL, the inside of the for loop x2 - & gt; Next is the incorrect access
CodePudding user response:
Fun