Advertisement
Guest User

bla bal;

a guest
Sep 20th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. struct nod{
  5. int inf;
  6. nod *next;
  7. };
  8.  
  9. int main()
  10. { nod *a,*b,*c;
  11. a=new nod;
  12. a->inf=4;
  13. a->next=0;
  14. cout<<a->inf;
  15. b=new nod;
  16. b->inf=5;
  17. b->next=a;
  18. cout<<b->inf<<" "<<a->inf;
  19. cout<<b->inf<<" "<<b->next->inf<<endl;
  20. c=new nod;
  21. c->inf=6;
  22.  
  23. cout<<c->inf<<" "<<b->inf<<" " <<a->inf<<endl;
  24. c->next=b;
  25. c->next->next=a;
  26. cout<<c->inf<<" "<<c->next->inf<<" " <<c->next->next->inf<<endl;
  27. /*
  28.  
  29. cout<<c->inf;
  30. c=c->next;
  31. cout<<c->inf;
  32. c=c->next;
  33. cout<<c->inf<<endl;
  34. //c=c->next;
  35. //cout<<c->inf; vrea sa afiseze inf de NULL
  36.  
  37. */
  38. /*/nod *p;
  39. p= new nod;
  40. cout <<endl;
  41. for(p=c; p!=0; p=p->next)
  42. cout<<p->inf<<" ";/*/
  43. //Liste simplu inlantuite alocate dinamic
  44. cout<<endl;
  45. nod *p,*u;
  46. p=u=new nod;
  47. p->inf=1;
  48. p->next=NULL;
  49. for(int i=2; i<=5; i++)
  50. {
  51. u->next=new nod;
  52. u=u->next;
  53. u->inf=i;
  54.  
  55. }
  56. u->next=NULL;
  57. for(nod*q=p; q; q=q->next)
  58. cout<<q->inf<<" ";
  59.  
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement