queue
unknown
plain_text
2 years ago
625 B
2
Indexable
#include <iostream> using namespace std; #define MAX_QUEUE 10000 class Queue { int A[MAX_QUEUE]; int front, rear; public: Queue(); bool is_Empty(); bool is_Full(); void enQueue(int inValue); int deQueue(); int Qpeek(); private: }; Queue::Queue(){ front = rear = -1; } bool Queue::is_Empty(){ if(front == rear) return true; return false; } bool Queue::is_Full(){ if(rear == MAX_QUEUE) return true; return false; } void Queue::enQueue(int inValue){ A[++rear] = inValue; } int Queue::deQueue(){ front++; return A[front]; } int Queue::Qpeek(){ return A[front + 1]; }
Editor is loading...