Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct nod {
- int info;
- nod* leg;
- };
- nod *creare()
- {
- nod *prim,*p,*q,*n;
- prim=new nod;
- q=prim;
- //cout<<"Info. din nodul 1: ";
- cin>>prim->info;
- if(prim->info==0)
- return NULL;
- while (q->info!=0)
- {
- p=new nod;
- //cout<<"Info. din nodul: "<<i;
- cin>>p->info;
- q->leg=p;
- n=q;
- q=p;
- }
- n->leg=NULL;
- p->leg=NULL;
- return prim;
- }
- void parcurge(nod* prim)
- {
- nod* p;
- p=prim;
- while(p)
- {
- cout<<p->info<<" ";
- p=p->leg;
- }
- }
- int main()
- {
- //nod *prim;
- parcurge(creare());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement