Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- Struct Nod
- {
- int cheie;
- Nod *next;
- };
- void adaug (Nod *& prim, int chnod)
- {
- Nod *nou = new Nod;
- nou->cheie = chnod;
- if(prim == NULL)
- nou->next = NULL;
- else
- nou->next = prim;
- prim = nou;
- }
- void sterg (Nod *& prim)
- {
- if (prim == NULL)
- {
- cout<<"Lista vida";
- return;
- }
- Nod *sters = prim;
- sters->next = prim;
- cout<<"Nodul sters "<<sters->cheie;
- delete []sters;
- }
- void parcurgere (Nod *prim)
- {
- Nod *n = prim;
- while (n!=NULL)
- {
- cout<<n->cheie;
- n=n->next;
- }
- }
- // lista vida
- int listavida (Nod *prim)
- {
- return prim==NULL;
- }
- //lista plina
- int listaplina (Nod *prim,int limsup)
- {
- int nr = 0;
- Nod *n = prim;
- while (n!=NULL)
- {
- nr++;
- n=n->next;
- }
- if(nr==limsup)
- {
- cout<<"lista plina!";
- }
- return;
- }
- void sterge_lista (Nod *&prim)
- {
- while (prim!=NULL)
- {
- Nod *sters = prim;
- prim=prim->next;
- delete []sters;
- }
- prim=NULL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement