Home > Back-end >  Tail interpolation output without a, how to change
Tail interpolation output without a, how to change

Time:10-05

#include

#include

# define OK 1

# define the ERROR 0

Typedef int ElemType;

Typedef int the Status;

Typedef struct LNode {

ElemType data;

Struct LNode * next;

} LNode * LinkList;

Void CreatList (LinkList & amp; Int L, n)//create a list head interpolation

{LinkList p; int i;//LinkList p or LNode * p

L=(LinkList) malloc (sizeof (LNode));

//L - & gt; Next==NULL;

L - & gt; Next=NULL;

For (I=n; I> 0; I -) {

P=(LinkList) malloc (sizeof (LNode));

The scanf (" % d ", & amp; (p - & gt; Data));

P - & gt; Next=L - & gt; Next;

L - & gt; Next=p;

}

}
Void CreatListTail (LinkList & amp; Int L, n)//create list tail interpolation

{LNode * s; int i;//LinkList p or LNode * p
LinkList r;
L=(LinkList) malloc (sizeof (LNode));

//L - & gt; Next==NULL;

L - & gt; Next=NULL;

R=L;

for(i=1; i
S=(LinkList) malloc (sizeof (LNode));

The scanf (" % d ", & amp; (s - & gt; Data));

S - & gt; Next=NULL;

R - & gt; Next=s;
R=s;

}

}

//Listprint (LinkList & amp; L)//chain table shows

The Status Listprint (LinkList & amp; L)//chain table shows

{

//LNode * p;

//p=L;

LNode * p=L - & gt; Next;

While (p!=NULL) {

Printf (" % 3 d ", p - & gt; The data);

P=p - & gt; Next;

}
printf("\n");

return OK;

}

Int main ()

{int x, n, I, e, ret.

LinkList H, T;

Printf (" input the length of a singly linked list \ n ");

The scanf (" % d ", & amp; X);

CreatList (H, x);

Listprint (H);

Printf (" input the length of a singly linked list \ n ");

The scanf (" % d ", & amp; N);

CreatListTail (T, n);
Listprint (T);
}

CodePudding user response:

R=L;

For ( I=1; i i++) {

S=(LinkList) malloc (sizeof (LNode));

Here I=0; i
  • Related