http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0013&lang=jp
#include <iostream> #include <vector> using namespace std; int main (int argc, const char * argv[]) { int read = 0; vector<int> num; while (cin >> read) { if(read == 0) { //pop cout << num[num.size() - 1] << "\n"; num.pop_back(); }else { //push num.push_back(read); } } return 0; }