Pagini recente » Cod sursa (job #1961430) | Cod sursa (job #1328531) | Cod sursa (job #1325440) | Cod sursa (job #21495) | Cod sursa (job #2423976)
struct Nod
{
int info;
Nod *st, *dr;
};
Nod *L, *U;
void Creare(int x)
{
L = new Nod;
U = L;
L->st = l->dr = NULL;
L->info = x;
}
void InsInainte(Nod *p, int x)
{
Nod *q = new Nod;
q->info = x;
q->dr = p;
q->st = p->st;
p->st->dr = q;
p->st = q;
}
void InsInceput(int x)
{
Nod *p = new Nod;
p->info = x;
p->dr = L;
p->st = NULL;
L->st = p;
L = p;
}
void Sterge(Nod *p)
{
if(L == NULL)
return;
if(L == U)
{
delete L;
L = U = NULL;
return;
}
if(p == L)
{
L = L->dr;
delete p;
l->st = NULL;
return;
}
if(p == U)
{
U = U->st;
delete p;
U->dr = NULL;
return;
}
p->st->dr = p->dr;
p->dr->st = p->st;
delete p;
}
void Parc()
{
for(Nod *p=L; p != NULL; p = p->dr)
cout << p->info << " ";
cout << "\n";
}