#include <stdlib.h> #include <stdio.h> #define FALSE 0 #define TRUE 1 typedef struct p { struct p *link; int val; } *pNode, node; int insert(register pNode *pLink, int new_val); int main() { pNode root = NULL; pNode *pLink = &root; int i; for (i = 0; i < 50; i+=3) insert(pLink, i); insert(pLink, 50); insert(pLink, 31); insert(pLink, -1); pNode p = root; while (p != NULL) { printf("%d ", p->val); p = p->link; } printf("/n"); return 0; } int insert(register pNode *pLink, int new_val) { register pNode current; register pNode pNewNode; while ((current = *pLink) != NULL && current->val < new_val) pLink = ¤t->link; pNewNode = (pNode)malloc(sizeof(node)); if (pNewNode == NULL) return FALSE; pNewNode->val = new_val; pNewNode->link = current; *pLink = pNewNode; return TRUE; }