作业帮 > 综合 > 作业

for(p = head; p->next = NULL; p = p->next);p->next =

来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:综合作业 时间:2024/04/29 01:15:37
for(p = head; p->next = NULL; p = p->next);p->next =
int insert(int id)
{
node_t *p,*q;
/* creat new node */
q = new_node(id);
if(q == NULL) return -1;
/* nothing in the link */
if(head == NULL){
head = q; return 0;
}
/* get the last one */
for(p = head; p->next = NULL; p = p->next);
/* get into the link */
p->next = q;
return 0;
}
最后那两句不太明白呀.q是最后一个结点么
for(p = head; p->next = NULL; p = p->next);p->next =
应该是一个链表指针p的遍历,直到结尾p==NULL