Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Establish a single linked list of leading nodes, and the range of nodes is plastic data. It is necessary to establish the corresponding single linked list online according to the data input by users.
Establish a single linked list of leading nodes, and the range of nodes is plastic data. It is necessary to establish the corresponding single linked list online according to the data input by users.
Here is the list of links you need:

# include & ltstdlib.h & gt

# include & ltstdio.h & gt

Structural node {

Int value;

Node * Next;

};

Node * buildList(int arr[],int n)

{

If(n == 0) returns NULL.

Node * head = new node ();

head->; value = arr[0];

head->; next = NULL

Node *p = head, * q;;

for(int I = 1; I & ltn;; i++) {

Q = new node ();

q->; value = arr[I];

q->; next = NULL

p->; next = q;

p = p-& gt; Next;

}

Return head;

}

Empty print list (node * header)

{

Node *p = header;

And (p! =NULL) {

printf("%d ",p-& gt; Value);

p = p-& gt; Next;

}

printf(" \ n ");

}

int main()

{

int n,a[ 100];

Printf ("Number of input nodes:");

scanf("%d ",& ampn);

Printf ("Value of input node:");

for(int I = 0; I & ltn;; i++)

scanf("%d ",& ampa[I]);

Node * list = buildList(a,n);

PrintList;

//float x;

//scanf("%f ",& ampx);

}