List Insert(List L, ElementType X)
{//创建结点List node = (List)malloc(sizeof(List));node->Data = X;node->Next = NULL;List head = L->Next; //定位real头指针//空链表 直接插入if (head == NULL) {L->Next = node;node->Next = head;return L;}//插入数据比第一个数据还小 直接插入if (head->Data >= X) {L->Next = node;node->Next = head;return L;}List prv = NULL;while (head && head->Data < X){prv = head;head = head->Next;}//循环结束条件一:head走到空都没有找到合适位置 尾插if (head == NULL){prv->Next = node;}循环结束条件二:找到合适位置else {prv->Next = node;//中node->Next = head;}return L;
}