n->next = w->next;
w->next = n;
n->Data = data;
return n;
}
List* del(List* w) // Ro‘yxatdan elementni o‘chirish
{
if(w->prev){w->prev->next = w->next;}
if(w->next){w->next->prev = w->prev;}
List * r;
if(w->next) {r = w->next;} else {r = w->prev;}
delete w;
return r;
}
List First; // Ro‘yxatning boshi
List* Last = &First; // Ro‘yxatning oxiri
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Memo1->Lines->Clear();
List* m = &First;
while(m)
{
Memo1->Lines->Add(m->Data);
m = m->next;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Last = add(Last,Edit1->Text);
Edit1->Text = "";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
Last = del(Last);
}
//---------------------------------------------------------------------------
Do'stlaringiz bilan baham: |