JustSaiyan4u

LISTE

Jan 14th, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct nod{
  5. int info;
  6. nod* adr;
  7. };
  8.  
  9. nod *v, *s;
  10.  
  11. void creare(nod* &v,nod* &s,int x)
  12. {
  13.     nod *c;
  14.     if(v==0)
  15.     {
  16.         v=new nod;
  17.         v->info=x;
  18.         v->adr=0;
  19.         s=v;
  20.     }
  21.     else{
  22.         c= new nod;
  23.         s->adr=c;
  24.         c->info=x;
  25.         c->adr=0;
  26.         s=c;
  27.     }
  28.  
  29. }
  30.  
  31. void tip(nod *v)
  32. {
  33.     nod *c=v;
  34.     while(c)
  35.     {
  36.         cout<<c->info<<" ";
  37.         c=c->adr;
  38.     }
  39. }
  40.  
  41. int main()
  42. {
  43. creare(v,s,7);
  44. creare(v,s,9);
  45. creare(v,s,11);
  46. tip(v);
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment