Advertisement
apl-mhd

BappySir Quoue

Apr 1st, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 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;
  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.     }
  29. }
  30. void Print(){
  31.     int R, F;
  32.  
  33.     F = (f+1) %(SIZE +1);
  34.     R = (r+1) % (SIZE+1);
  35.  
  36.     while(R !=F){
  37.  
  38.             cout<<number[F]<<" ";
  39.  
  40.             F = (F+1) % (SIZE +1);
  41.  
  42.  
  43.         }
  44.  
  45. }
  46.  
  47.  
  48.  
  49. int main()
  50. {
  51.  
  52.   Enquue(10);
  53.   Enquue(20);
  54.   Enquue(40);
  55.   Deque();
  56.   Enquue(30);
  57. Print();
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement