回复 10楼 alice_usnet


大神v5, 那关于那个return 1,我要写一个if条件是吗?


大神v5, 那关于那个return 1,我要写一个if条件是吗?
2016-04-13 15:37
程序代码: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编辑过]

2016-04-13 15:54
2016-04-13 16:22