Advertisement
edutedu

liste2

Oct 9th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct nod {
  6. int info;
  7. nod* leg;
  8. };
  9.  
  10.  
  11. nod *creare()
  12. {
  13. nod *prim,*p,*q,*n;
  14. prim=new nod;
  15. q=prim;
  16. //cout<<"Info. din nodul 1: ";
  17. cin>>prim->info;
  18. if(prim->info==0)
  19. return NULL;
  20. while (q->info!=0)
  21. {
  22. p=new nod;
  23. //cout<<"Info. din nodul: "<<i;
  24. cin>>p->info;
  25. q->leg=p;
  26. n=q;
  27. q=p;
  28. }
  29. n->leg=NULL;
  30. p->leg=NULL;
  31. return prim;
  32. }
  33.  
  34. void parcurge(nod* prim)
  35. {
  36. nod* p;
  37. p=prim;
  38. while(p)
  39. {
  40. cout<<p->info<<" ";
  41. p=p->leg;
  42. }
  43. }
  44.  
  45. int main()
  46. {
  47. //nod *prim;
  48. parcurge(creare());
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement