Advertisement
STANAANDREY

stiva(basic)

Jul 7th, 2019
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. bool isEmpty(int n)
  5. {
  6.     if (!n)
  7.     return false;
  8.     return true;
  9. }
  10.  
  11. int peek(int stiva[],int n)
  12. {
  13.     return stiva[n];
  14. }
  15.  
  16. void PUSH(int stiva[],int &n,int x)
  17. {
  18.      stiva[++n]=x;
  19. }
  20.  
  21. int POP(int stiva[],int &n)
  22. {
  23.     int r=peek(stiva,n);
  24.     n--;
  25.     return r;
  26. }
  27.  
  28. int main()
  29. {
  30. int stiva[100], k = 0;
  31.     PUSH(stiva, k, 2);
  32.     PUSH(stiva, k, 4);
  33.     PUSH(stiva, k, 6);
  34.     PUSH(stiva, k, 7);
  35.     PUSH(stiva, k, 8);
  36.     cout << POP(stiva, k);
  37.     cout << POP(stiva, k);
  38.     cout << POP(stiva, k);
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement