Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct nod{
- int inf;
- nod *next;
- };
- int main()
- { nod *a,*b,*c;
- a=new nod;
- a->inf=4;
- a->next=0;
- cout<<a->inf;
- b=new nod;
- b->inf=5;
- b->next=a;
- cout<<b->inf<<" "<<a->inf;
- cout<<b->inf<<" "<<b->next->inf<<endl;
- c=new nod;
- c->inf=6;
- cout<<c->inf<<" "<<b->inf<<" " <<a->inf<<endl;
- c->next=b;
- c->next->next=a;
- cout<<c->inf<<" "<<c->next->inf<<" " <<c->next->next->inf<<endl;
- /*
- cout<<c->inf;
- c=c->next;
- cout<<c->inf;
- c=c->next;
- cout<<c->inf<<endl;
- //c=c->next;
- //cout<<c->inf; vrea sa afiseze inf de NULL
- */
- /*/nod *p;
- p= new nod;
- cout <<endl;
- for(p=c; p!=0; p=p->next)
- cout<<p->inf<<" ";/*/
- //Liste simplu inlantuite alocate dinamic
- cout<<endl;
- nod *p,*u;
- p=u=new nod;
- p->inf=1;
- p->next=NULL;
- for(int i=2; i<=5; i++)
- {
- u->next=new nod;
- u=u->next;
- u->inf=i;
- }
- u->next=NULL;
- for(nod*q=p; q; q=q->next)
- cout<<q->inf<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement