/* 4. ´ÙÀ½ ÇÁ·Î±×·¥ÀÇ Ãâ·ÂÀ» ½á¶ó. */ #include class Node { public: int data; Node *next; Node(int d, Node *n) { data = d; next = n; } }; class Queue { Node *head; Node *tail; public: Queue() { head = new Node(0,NULL); tail = head; } void add(int x) { head = new Node(x,head); tail->next = new Node(x,NULL); tail = tail->next; } void remove() { head = head->next; } void print() { while(head != NULL) { printf("%d ",head->data); head = head->next; } } }; void main() { int data[5] = { 1, 2, 3, 4, 5 }; // ¿©±â¸¦ ¹Ù²Ü °Í Queue x; for(int i = 0; i < 5; i++) { x.add(data[i]); } for(i = 0; i < 5; i++) { x.remove(); } x.print(); }