Cpp에서 Stack과 Queue를 사용하는 간단한 방법입니다.
#include <iostream> #include <stack> #include <queue> using namespace std; int main() { cout << "-----------------Stack-----------------" << endl; cout << endl; stack<int> 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<int> 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; }
[C++] Stack과 Queue 사용법
Reviewed by 재미주의
on
9월 29, 2018
Rating:
댓글 없음: