# Include "stdafx. H"
# Include "stdlib. H"
Typedef struct Node
{
Int data;
Node * next;
};
Void insert (node * s, node *)
{
Node * P, * q;
P = NULL;
Q = NULL;
P = s;
If (p-> next = NULL) // empty linked list
{
P-> next = A; // A-> next is null.
S-> DATA = s-> Data + 1;
Return;
}
Q = P;
P = p-> next; // The linked list is not empty and points to the first node.
While (P! = NULL) & (p-> data <A-> data) // locate the appropriate insert Node
{
Q = P;
P = p-> next;
}
If (P = NULL) // you need to insert the end Of the link.
{
Q-> next = A; // A-> next is null.
S-> DATA = s-> Data + 1;
Return;
}
If (p-> DATA> = A-> data) // you need to insert the link intermediate node.
{
A-> next = P;
Q-> next =;
S-> DATA = s-> Data + 1;
Return;
}
}
Void main (INT argc, char * argv [])
{
Node * head = NULL;
Node * temp;
Int N;
Head = (node *) malloc (sizeof (node ));
Head-> DATA = 0; // chain table length, initially 0
Head-> next = NULL; // The linked list is empty.
Int I;
For (I = 0; I <5; I ++)
{
Printf ("input a integer/N ");
Scanf ("% d", & N );
Node * A = (node *) malloc (sizeof (node ));
A-> DATA = N;
A-> next = NULL;
Insert (Head, );
}
Printf ("the total node is % d/N", head-> data );
Temp = head-> next;
While (temp)
{
Printf ("% d/N", temp-> data );
Temp = temp-> next;
}
}