The idea of head-inserting is to build a head knot, point yourself to yourself, and then come to a new node.
Let the new node point to the node that the head node points to, and then let the head node point to the new node.
In this way, the new node will always be inserted into the end of the knot is the head interpolation method.
C Language Programming implementation
#include <stdio.h>
#include <malloc.h>
struct list {
int A;
struct list * next;
} ;
struct list * head;
struct list * P=NULL;
int main () {
printf ("%s\n", "Please enter the length of the list)";
int length=0,i,data;
scanf ("%d", &length);
printf ("%s\n", "Enter the data in the list sequentially");
Head = (struct list *) malloc (sizeof (struct list));
head->next=null;
for (i=0;i<length;i++) {
p = (struct list *) malloc (sizeof (struct list));
scanf ("%d", &p->a);
p->next=head->next;
head->next=p;
}
while (p!=null) {
printf ("%d ", p->a);
p=p->next;
}