Kod:
#include <iostream>
using namespace std;
class veri{
public:
int a;
veri* next,*back;
};
class liste{
int sayac;
veri* head,*current;
public:
liste(){
sayac=0;
}
**** baslat(int y){
head=new veri;
head->a=y;
current=new veri;
head->next=current;
current->back=head;
}
**** ekle(int y){
current->a=y;
current->next=new veri;
current->next->back=current;
current=current->next;
sayac=sayac+1;
}
**** sil(int y){
veri* plm=head,*plm2=head;
if(y==head->a){
head=head->next;
delete plm2;
sayac--;
sil(y);
}
if(y==current->a){
for(int i=0;i<=sayac-1;i++){
plm=plm->next;
plm2=plm2->next;
}
plm->next=current->next;
plm2->next=current->next;
plm->back=current->back;
plm2->back=current->back;
delete current;
sayac--;
sil(y);
}
for(int i=0;i<=sayac;i++){
if(y==plm->a){
plm2->back=plm->back;
plm2->next=plm->next;
delete plm;
sayac--;
sil(y);
}
plm=plm->next;
plm2=plm2->next;
}
}
int len(){
return sayac;
}
int uzunluk(){
return sayac;
}
veri* getItemAt(int y){
veri* plm=head;
for(int i=0;i<y;i++){
if(plm->next){
plm=plm->next;
}
}
return plm;
}
**** yazdir(){
veri* plm=head;
for(int i=0;i<=len();i++){
cout<<plm->a<<" "<<plm->next<<" "<<plm->back<<endl;
plm=plm->next;
}
}
};
int main(){
liste plm;
plm.baslat(1);
for(int i=2;i<=4;i++){
plm.ekle(i);
}
plm.sil(1);
plm.yazdir();
char y;cin>>y;
}