C++ 스택 push()


개요

C++ 스택 push()
#include <iostream>
#include <stack>
using namespace std;

int main () {
  stack<int> s;
  s.push(1);
  s.push(2);
  while(!s.empty()) {
      cout << s.top() << endl;
      s.pop();
  }
}
#include <iostream>
#include <stack>
#include <utility>
using namespace std;

int main () {
  stack<pair<int,int>> s;
  s.push(pair<int,int>(1,2));
  s.push(pair<int,int>(3,4));
  while(!s.empty()) {
      cout << s.top().first << ',' << s.top().second << endl;
      s.pop();
  }
}

같이 보기

참고