제목 그대로 스택과 큐를 사용하는 간단한 소스코드입니다.

#include 
#include 
#include 

using namespace std;

int main()
{
	cout << "-----------------Stack-----------------" << endl;

	cout << endl;

	stack st;

	st.push(1);
	st.push(2);
	st.push(3);

	int count = st.size();
	for(int i=0; i < count; i++){
		cout << st.top() << endl;
		st.pop();
	}

	cout << endl;
	cout << endl;

	cout << "-----------------Queue-----------------" << endl;

	cout << endl;

	queue qu;
	
	qu.push(1);
	qu.push(2);
	qu.push(3);

	count = qu.size();
	for(int i=0; i < count; i++){
		cout << qu.front() << endl;
		qu.pop();
	}

	return 0;
}
저작자 표시 비영리 변경 금지

'Language > C / C++ for Windows' 카테고리의 다른 글

메시지 크래커 사용하기  (0) 2010/10/20
[C++0x] Visual Studio 2010에 포함된 C++0x  (0) 2010/04/29
[STL] Stack과 Queue 사용법  (0) 2009/10/01
Posted by 태발이

댓글을 달아 주세요