Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream.h>
- #include <conio.h>
- struct nod{int info; nod *ad;};
- nod *v,*sf;
- int nr;
- void adaugare(nod *v,int nr,nod *&sf)
- {
- nod *c;
- if (v==0)
- {
- v=new nod;
- v->info=nr;
- v->ad=0;
- sf=v;
- }
- else
- {
- c=new nod;
- c->info=nr;
- c->ad=0;
- sf->ad=c;
- sf=c;
- }
- }
- void afisare (nod *v)
- {
- nod *c;
- while(c!=0)
- {
- cout<<c->info;
- c=c->ad;
- }
- }
- void main()
- {
- for(int i=1;i<=10;i++)
- adaugare (v,i,sf);
- afisare (v);
- getch();}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement