挽txt微盘:用C写一个小程序。高手帮忙呀。急!!!谢谢大侠了!!!

来源:百度文库 编辑:高考问答 时间:2024/05/11 00:53:57
Given a node structure as below:
Struct Node
{
int data;
Node * next;
};

Write a list insertion function for an ordered list.

void insert(Node *phead, int a, int b)
{

Node *p, *q;
q = (Node *)malloc(sizeof(Node));
q -> data = b;
q -> next = NULL;
if(*phead == NULL)
*phead = q;
else
{
p = *phead;

while(p -> data != a && p -> link != NULL)
p = p -> link;

q -> link = p -> link;
p -> link = q;
}
}

插入结点的算法嘛