티스토리 뷰
2017.1.17
#include< iostream > using namespace std; #define MAX_QUEUE_SIZE 100; class CircularQueue{ protected: int front; int rear; int data[MAX_QUEUE_SIZE]; public: CircularQueue(){front=rear=0;} bool isFull(){ return (rear+1)%MAX_QUEUE_SIZE==front; } bool isEmpty(){ return rear==front; } void enqueue(int x){ if(isFull()) printf("포화상태입니다."); else{ rear=(rear+1)%MAX_QUEUE_SIZE; data[rear]=x; } } int dequeue(){ if(isEmpty()) printf("공백상태입니다."); else{ front=(front+1)%MAX_QUEUE_SIZE; return data[front]; } } int peek(){ if(isEmpty()) printf("공백상태입니다."); else return data[(front+1)%MAX_QUEUE_SIZE]; } };
과제.
● https://www.acmicpc.net/problem/10845 : 큐 구현
● https://www.acmicpc.net/problem/1966 : 프린터 큐
● https://www.acmicpc.net/problem/10866 : 덱
#자료 첨부
댓글