数据结构c语言编程 急求!!!!

设线性表L中的数据元素为整数,通增有序,编写一个算法,计算值为X的数据元素个数并输出,刑除值为X的数据元素
求完整程序加算法实

//在一个递增有序的线性表L中插入一个值为x的元素,并保持其递增有序特性
bool listInsert(node* L, elementType x)
{
//注意:带有空的头结点L
node* p = L->next;
node* s = new node;// 创建一个新节点
s->data = x;//装入数据
if (p->data >= x)//排在第一的特例
{
s->next = L->next;//插入操作
L->next = s;
return true;
}
while ((p != NULL) && (p->next != NULL)) //搜索ai-1节点指针
{
if (p->next->data >= x && p->data < x)
{
//插入新节点
s->next = p->next;
p->next = s;
return true;
}
p = p->next;
}
//排在最后的情况
//插入新节点
s->next = NULL;
p = s;
return true;
}
【答题不易,请采纳谢谢】
温馨提示:答案为网友推荐,仅供参考
相似回答