#include<stdio.h>
#include<queue>
std::queue<int>Q; //정수 Q 선언
int main()
{
for(int i=1; i<=3; i++) //큐에 1, 2, 3 순서대로 삽입
Q.push(i);
for(int i=1; i<=2; i++) //큐 가장 앞에 있는 값을 출력하며 제거 2회
{
printf("%d ", Q.front());
Q.pop();
}
printf("\n");
Q.push(4); //큐에 4 삽입
Q.push(5); //큐에 5 삽입
while(!Q.empty()) //모두 비워질 때까지 큐의 값을 출력하며 제거
{
printf("%d ", Q.front());
Q.pop();
}
printf("\n");
}
/*
1 2
3 4 5
--------------------------------
Process exited after 0.02704 seconds with return value 0
계속하려면 아무 키나 누르십시오 . . .
*/
댓글