Advertisement
STANAANDREY

Coada(basic)

Jul 7th, 2019
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 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 FRONT(int coada[],int n)
  12. {
  13.     return coada[1];
  14. }
  15.  
  16. void PUSH(int coada[],int &n,int x)
  17. {
  18.     coada[++n]=x;
  19. }
  20.  
  21. int POP(int coada[],int &n)
  22. {
  23.     int r=FRONT(coada,n);
  24.     for (int i=1; i<n; i++)
  25.         coada[i]=coada[i+1];
  26.         n--;
  27.     return r;
  28. }
  29.  
  30.  
  31.  
  32. int main()
  33. {
  34.     int coada[100],k=0;
  35.     PUSH(coada, k, 2);
  36.     PUSH(coada, k, 4);
  37.     PUSH(coada, k, 6);
  38.     PUSH(coada, k, 7);
  39.     PUSH(coada, k, 8);
  40.     cout << POP(coada, k);
  41.     cout << POP(coada, k);
  42.     cout << POP(coada, k);
  43.     cout << POP(coada, k);
  44.     cout << POP(coada, k);
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement