Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<fstream>
- using namespace std;
- struct NOD
- {
- int inf;
- NOD *urm,*ant;
- };
- void creare(int x)
- {
- prim=new NOD;
- prim->urm=prim->ant=NULL;
- ultim=prim;
- }
- void adaugare(int x)
- {
- NOD *nou;
- nou=new NOD;
- nou->inf=x;
- nou->urm=NULL;
- ultim->urm=nou;
- nou->ant=ultim;
- ultim=nou;
- }
- void adaugaref(int x)
- {
- NOD *nou;
- nou=new NOD;
- nou->inf=x;
- nou->ant=NULL;
- nou->urm=prim;
- prim->ant=nou;
- prim=nou;
- }
- void afisare2()
- {
- NOD *p;
- p=ultim;
- while(p!=NULL)
- {
- cout<<p->inf<<" ";
- p=p->ant;
- }
- }
- int main()
- {
- ifstream in("lista.in");
- int x;
- in>>x;
- creare(x);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement