Adaugare, Afisare, Stergere
#include<iostream>
#include<fstream>
using namespace std;
struct nod{int info;
nod* urm;};
void adaugare(nod* &prim, nod* &ultim, int x)
{nod* p=new nod;
p->info=x;
p->urm=NULL;
if(prim==NULL)
prim=p;
else ultim->urm=p;
ultim=p;}
void afisare(nod* prim)
{if(prim==NULL)
cout<<"Coada goala";
else while(prim)
{cout<<prim->info<<" | ";
prim=prim->urm;}
cout<<endl;
}
void stergere(nod* &prim, int k)
{nod* p;
while(k && prim)
{p=prim;
prim=prim->urm;
delete p;
k--;}
}
int main()
{ifstream f("date");
int x,k;
nod* prim=NULL;
nod* ultim=NULL;
cin>>k;
while(f>>x)
adaugare(prim,ultim,x);
afisare(prim);
adaugare(prim,ultim,2);
stergere(prim,k);
afisare(prim);
}