填空题

设线性链表的存储结构如下:
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;}
}
}


您可能感兴趣的试卷

你可能感兴趣的试题