Advertisement
apl-mhd

Bappy Sir queue

Mar 30th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #define SIZE 3
  4. int number[SIZE+1];
  5. int f=0,r=0,start=1;
  6.  
  7. void Enquue(int x){
  8.  
  9.   int  s = (r+1) % (SIZE +1);
  10.  
  11.     if(s== f) cout<<"FULL"<<endl;
  12.     else{
  13.  
  14.         r=s;
  15.         number[r] = x;
  16.     }
  17.  
  18.       //start =  ((f+1) % (SIZE+1)) + 1 ;
  19. }
  20. void Deque(){
  21.  
  22.     if(f==r) cout<<"Empty"<<endl;
  23.  
  24.     else{
  25.  
  26.         f = (f+1) % (SIZE+1);
  27.  
  28.         start = f+1;
  29.  
  30.  
  31.     }
  32.  
  33.  
  34. }
  35.  
  36.  
  37.  
  38. int main()
  39. {
  40.  
  41.   Enquue(10);
  42.   Enquue(20);
  43.   Enquue(30);
  44.   Deque();
  45.   Enquue(40);
  46.  
  47.  
  48.  //cout<<start<<endl;
  49.  
  50.  
  51.   for(int i=start; i<=r; i++)
  52.         cout<<number[i]<<" ";
  53.  
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement