sa1378
پنج شنبه 02 مرداد 1393, 16:21 عصر
سلام
این کد ها عضو اخر linkedlist رو حذف میکنن
فرقشون چیه؟
اولی:
struct LinkedList *temp;
temp=new LinkedList;
for(; head!=NULL ; head=head->next )
{
temp=head;
}
delete head;
temp->next=NULL;
دومی :
for(; head->next->next!=NULL ; head=head->next );
delete head->next;
head->next=NULL;
یکیشون کار نمیکنه و یکی دیگه سالمه
این کد ها عضو اخر linkedlist رو حذف میکنن
فرقشون چیه؟
اولی:
struct LinkedList *temp;
temp=new LinkedList;
for(; head!=NULL ; head=head->next )
{
temp=head;
}
delete head;
temp->next=NULL;
دومی :
for(; head->next->next!=NULL ; head=head->next );
delete head->next;
head->next=NULL;
یکیشون کار نمیکنه و یکی دیگه سالمه