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->nex
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/24 08:21:53
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->nex
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 = 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->nex
应该是一个链表指针p的遍历,直到结尾p==NULL