티스토리 뷰
2017.1.17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #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 : 덱
#자료 첨부