Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- STIVA :
- struct nods{ int inf; nods*ant;};
- nods *vf;
- void adauga(nods *&vf, int x)
- {
- if(vf==NULL)
- {
- vf=new nods;
- vf->inf=x;
- vf->ant=NULL;
- }
- else
- {
- nods *nou;
- nou=new nods;
- nou->inf=x;
- nou->ant=vf;
- vf=nou;
- }
- }
- void parcurge(nods *vf)
- {
- nods *p;
- p=vf;
- while(p!=NULL)
- {
- // prelucram p->inf
- p=p->ant;
- }
- }
- void sterge(nods *vf)
- {
- nods *p;
- p=vf;
- vf=vf->ant;
- delete p;
- }
- COADA :
- struct nodc{ int inf; nodc*urm;};
- nodc *prim,*ultim;
- void adauga(nodc *&prim, nodc *&ultim, int x)
- {
- if(prim==NULL)
- {
- prim=new nodc;
- prim->inf=x;
- prim->urm=NULL;
- ultim=prim;
- }
- else
- {
- nodc *nou;
- nou=new nodc;
- nou->inf=x;
- nou->urm=NULL;
- ultim->urm=nou;
- ultim=nou;
- }
- }
- void parcurge(nodc *prim)
- {
- nodc *p;
- p=prim;
- while(p!=NULL)
- {
- // prelucram p->inf
- p=p->urm;
- }
- }
- void sterge(nodc *&prim, nodc *&ultim)
- {
- nodc *p;
- p=prim;
- prim=prim->urm;
- delete p;
- }
- LISTA SIMPLU INLANTUITA :
- struct nodl{ int inf; nodl*urm;};
- nodc *prim,*ultim;
- void adauga(nodl *&prim, nodl*&ultim, int x)
- {
- if(prim==NULL)
- {prim=new nodl;
- prim->inf=x;
- prim->urm=NULL;
- ultim=prim;}
- else
- {nodl *nou;
- nou->inf=x;
- nou->urm=NULL;
- ultim->urm=nou;
- ultim=nou;}
- }
- LISTA DUBLU INALNTUITA :
- struct nodd{ int inf; nodd*urm,*ant;};
- nodd *prim,*ultim;
- void adauga(nodd *&prim, nodd*&ultim, int x)
- {
- if(prim==NULL)
- {prim=new nodd;
- prim->inf=x;
- prim->ant=NULL;
- prim->urm=NULL;
- ultim=prim;}
- else
- {nodd *nou;
- nou->inf=x;
- nou->urm=NULL;
- nou->ant=ultim;
- ultim->urm=nou;
- ultim=nou;}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement