Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement