设线性链表的存储结构如下: struct node {ELEMTP data; struct node *next; } 试完成下列在链表中值为x的结点前插入一个值为y的新结点。如果x值不存在,则把新结点插在表尾的算法。 void inserty(struct node *head,ELEMTP x,ELEMTP y) {s=(struct node *)malloc(sizeof(struct node)); (); if(){s->nexr=head;head=s;} else { q=head;p=q->next; while(p->dqta!=x&&p->next!=NULL){q=p;()} if(p->data= = x){q->next=s;s->next=p;} else{p->next=s;s->next=NULL;} } }
出自:计算机科学