ann8497

queue

Aug 14th, 2019
699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. struct node{
  2.   int x;
  3.   int y;
  4.   int level;
  5. };
  6.  
  7. node q[1000];
  8. int front = 0;
  9. int back = 0;
  10.  
  11. void init(){
  12.   front = back = 0;
  13. }
  14.  
  15. void push(int x, int y, int level){
  16.   q[back].x = x;
  17.   q[back].y = y;
  18.   q[back].level = level;
  19.   back++;
  20. }
  21.  
  22. node pop(){
  23.   return q[front++];
  24. }
  25.  
  26. bool empty(){
  27.    return (front == back);
  28. }
Add Comment
Please, Sign In to add comment