Static and dynamic lists are two different representations of a linear chain-linked storage structure.
Static linked list of the initial length is generally fixed, in the INSERT and delete operations do not need to move elements, only need to modify pointers, it is still a chain storage structure of the main advantages.
The dynamic linked list is relative to the static linked list, generally, when describing the chain storage structure of the linear table, if there is no special description, the default description is the dynamic linked list.
The following is a simple implementation of the linear table more detailed C language implementation, you can refer to the http://www.cnblogs.com/choon/p/3876606.html
Static linked list
#define _crt_secure_no_deprecate#define _crt_secure_cpp_overload_standard_names 1#include <stdio.h> #include <stdlib.h>/* all nodes are defined in the program, not temporarily opened up, and can not be used up after release, this list is called "Static linked list." */struct student{int num;float score;struct Student *next;}; int main () {struct Student stu1, STU2, Stu3, *head, *p;stu1.num = 1001; stu1.score = 80;//Assignment of NUM and STU1 members to node score Stu2.num = 1002; Stu2.score = 85; The NUM and score members of the node stu2 are assigned stu3.num = 1003; Stu3.score = 90; Assign the NUM and score members of the node stu3 head = &stu1; The head pointer points to the 1th node Stu1stu1.next = &stu2; Assign the address of the node STU2 to the next member of the STU1 node Stu2.next = &stu3; Assigns the address of the node STU3 to the next member of the STU2 node stu3.next = NULL; STU3 is the last node whose next member does not store any node address, set to NULLP = head; The P pointer also points to the 1th node//traverse static list do{printf ("%d,%f\n", P->num, P->score);//output P points to the node's data P = p->next; Then let P point to the next node} while (P! = NULL); Until the next member of P is null, the traversal system ("pause") is completed;}
Dynamic linked list
#define _crt_secure_no_deprecate#define _crt_secure_cpp_overload_standard_names 1#include <stdio.h> #include <stdlib.h>/*, the so-called dynamic linked list, refers to the process of the execution of a chain list from scratch, that is, one by one to open up the node and input the data, and establish the relationship between the front and back phase chain. */struct student{int no;//Study number struct Student *next;}; int main () {struct Student *p1, *p2, *head;int n = 0;//node number head = NULL;P1 = (struct Student *) malloc (sizeof (struct Student );p rintf ("Please enter 1 numbers \ n"), scanf ("%d", &p1->no);p 2 = p1; At the beginning, p1 and P2 both point to the 1th node while (p1->no! = 0) {n++;if (n = = 1) {head = P1;} Else{p2->next = p1;} P2 = p1;//p2 is the last node printf ("Please enter the study number, enter 0 termination: \ n");p 1 = (struct Student *) malloc (sizeof (struct Student)); scanf ("%d", &p1- >no);}; P2->next = null;//After the input is complete, p2->next iterates over the dynamic list struct Student *p;p = Head;while (P! = NULL) {printf ("%d,", p->no) for null//; p = P-Next;} printf ("\ n"); system ("Pause");}