#include<iostream> #define LEN 5010 using namespace std; int Q[LEN],hand=0,tail=0; void enqueue(int x); int dequeue(); bool isEmpty(); int main() { } void enqueue(int x) { Q[tail]=x; tail=(tail+1)%LEN; } int dequeue() { if(isEmpty()) { hand=(hand+1)%LEN; return Q[hand-1]; }else return 0; } bool isEmpty() { if(tail==hand) return 0; else return 1; }