#include
#include
Struct List
{
Int Datenum;
List * next;
}; // silly boy !! cogot;
Typedef List Node;
TypeDef node * link;
// Release of the list
Void Freelist (Link Head)
{
Link Pointer;
While (Head! = null)
{
Pointer = HEAD;
HEAD = head-> next;
FREE (POINTER);
}
}
// output of the list
Void OutputList (Link Head)
{
Link Pointer;
Pointer = HEAD;
While (Pointer! = NULL)
{
Printf ("Datanumber:% D / N", Pointer-> Datenum);
Pointer = POINTER-> NEXT;
}
}
// Establishment of the list
Link Createlist (Link Head) / / Returns Head Node
{
INT DATANUM = 1;
Link Pointer;
Link newNode;
HEAD = (link) Malloc (sizeof (node));
IF (head == null)
Printf ("Failed to Allocate Memory! / N");
Else {
Printf ("Please Input Number of List (0 means quit):");
Scanf ("D%", Head-> Datenum);
HEAD-> next = NULL;
Pointer = HEAD;
While (1)
{
Printf ("Please Input Number of List (0 means quit):");
Scanf ("% D", DATANUM);
IF (datanum == 0)
Break; // exit
// If you don't quit?
NewNode = (link) Malloc (sizeof (node);
NewNode-> Datenum = Datanum
NewNode-> next = null;
Pointer-> Next = newNode;
Pointer = newNode;
}
}
Return head;
}
void main ()
{
Link head;
Head = CREATELIST (HEAD);
IF (Head! = null)
{
OutputList (HEAD);
Freelist (Head);
}
}