Facebook
From Tinct Bat, 7 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 331
  1. #include <iostream>
  2. #include <stack>
  3.  
  4. using namespace std;
  5.  
  6. int dane[100];
  7. int rozmiar;
  8.  
  9. void wyswietl_stos()
  10. {
  11.     for (int i=rozmiar; i>=1; i--)
  12.     {
  13.         cout<<dane[i]<<endl;
  14.     }
  15.  
  16.     if (rozmiar==0) cout<<" "<<endl;//pusty
  17. }
  18.  
  19. void push()
  20. {
  21.     if (rozmiar<100)
  22.     {
  23.          rozmiar=rozmiar+1;
  24.          cin>>dane[rozmiar];
  25.     }
  26. }
  27.  
  28.  
  29. void pop()
  30. {
  31.     if (rozmiar>=1)
  32.     {
  33.         rozmiar=rozmiar-1;
  34.     }
  35.     else
  36.     {
  37.         cout << "error";
  38.     }
  39. }
  40.  
  41. void empty()
  42. {
  43.  
  44.     if (rozmiar==0) cout<<endl<<"error";
  45. }
  46.  
  47. int main()
  48. {
  49.  
  50.     char wybor;
  51.     rozmiar=0;
  52.  
  53.     do
  54.     {
  55.         wyswietl_stos();
  56.         cin >> wybor;
  57.  
  58.         switch (wybor)
  59.         {
  60.         case 'push\0':
  61.             push();
  62.             break;
  63.  
  64.         case 'pop\0':
  65.             pop();
  66.             break;
  67.         }
  68.  
  69.     }
  70.     while (wybor != 'end\0');
  71.  
  72.  
  73.     return 0;
  74. }
  75.  

Replies to Untitled rss

Title Name Language When
Re: Untitled Capacious Sloth text 7 Years ago.