Guest User

Untitled

a guest
Feb 18th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. void CzyPusty(liczba **root)
  2. {
  3.     if(*root==0){cout<<"Stos pusty";}
  4.     else
  5.         {
  6.             cout<<endl;
  7.             cout<<"Stos nie jest pusty"<<endl;
  8.             cout<<"Czy chcesz wyswietlic ilosc liczb na stosie? 1-tak; 2-nie"<<endl;
  9.             char znak;
  10.             cin>>znak;
  11.             if(znak=='1')
  12.             {
  13.               IleElementow(root);
  14.             }
  15.         }
  16. }
  17.  
  18. void IleElementow(liczba **root)
  19. {
  20.     vector <int> kontener;
  21.     int ile=0;
  22.     while(*root)
  23.     {
  24.         liczba *temp=*root;
  25.         *root=(*root)->wskaznik;
  26.         kontener.push_back(temp->wartosc);
  27.         delete temp;
  28.         ++ile;
  29.     }
  30.     int i=0;
  31.     cout<<"Liczb na stosie: "<<ile<<endl;
  32.     while(ile!=0)
  33.     {
  34.         liczba *nowa=new liczba;
  35.         nowa->wartosc=kontener[i];
  36.         ++i;
  37.         nowa->wskaznik=*root;
  38.         *root=nowa;
  39.         --ile;
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment