回复 10楼 alice_usnet



int add(IteratorInt it, int v){ // implement this function Node *new; new = malloc(sizeof(Node)); if(new==NULL) return 0; /*分配失败的情况*/ new->value = v; if(it->first==NULL){ /*判断一下是不是第一个结点*/ new->next=NULL; new->prev=NULL; it->first=new; it->curr=new; } else if(it->curr->next==NULL){ /*是否尾结点*/ new->next=NULL; new->prev=it->curr; it->curr->next=new; } else { new->next = it->curr->next; it->curr->next->prev=new; it->curr->next=new; new->prev=it->curr; it->curr=it->curr->next; } return 1; /*直接改成1*/// you need to change this... }
[此贴子已经被作者于2016-4-13 16:02编辑过]