기본 vector로도 stack의 기능을 어느 정도 구현할 수 있지만, 만들어 놓은 stack을 사용하자.
헤더파일 : #include <stack>
사용법 : vector와 같다.
stack<int> st;
함수
push(원소) : stack의 top에 원소 삽입
pop() : stack의 top에 있는 원소 삭제
top() : stack의 top에 있는 원소 리턴
size() : stack의 크기 리턴
empty() : stack이 비어있다면 true 리턴
stack<int> s;
s.push(12);
cout<<s.top()<<endl;
// 12 출력
s.pop();
<How to 코테 with C++> 4. 대문자, 소문자 변환 (0) | 2023.03.16 |
---|---|
<How to 코테 with C++> 2. find, erase (0) | 2023.03.09 |
<How to 코테 with C++> 1. Vector (0) | 2023.03.08 |