Go: package main

import (
        "fmt"
)

func main() {
        var stk [101]int
        var c int
        pvt := 0
        for {
                _, err := fmt.Scanf("%d", &c)
                if err != nil {
                        break
                }
                if c > 0 {
                        stk[pvt] = c
                        pvt++
                } else {
                        pvt--
                        fmt.Printf("%d\n", stk[pvt])
                }
        }
}

C++: #include<cstdio>
#include<cmath>
 
//#include<iostream>
using namespace std;
 
int main(){
int i=0, j, ar[11];

	while( scanf("%d" , &j)!= EOF){
		if(j!=0)	ar[++i]=j;
		else 		printf("%d\n",ar[i--]);
	}

    return 0;
}

C++: #include<stdio.h>

int main(){
	int car[11],i=0,n;
	do{
		scanf("%d",&n);
		if(n){
			car[i]=n;
			i++;
		}else{
			i--;
			printf("%d\n",car[i]);
			
		}
	}while(1);
}

C++: #include<iostream>
#include<stack>
using namespace std;

int main(){
  stack<int> car;
  int n,cou=0,i=0,ans[1111];
  while(cin >> n){
    if(n == 0){
      cout << car.top() << endl;
      car.pop();
    }
    else{
      car.push(n);
    }
  }
}

C++: #include <iostream>
#include <stack>
using namespace std;

int main(){
	int n,count = 0;
	stack<int> get;
	while(1){
		cin >> n;
		if(n==0){
			cout <<  get.top() << endl;
			get.pop();
			count -= 1;
		}
		else{
			get.push(n);
			count += 1;
		}
		//if(count == 0) break;
	}
	return 0;
}

C++: #include<iostream>
#include<stack>
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  stack<int> s;
  int n;
  while(cin>>n){
    if(n!=0)s.push(n);
    else{
      cout <<s.top() <<endl;s.pop();
    }
  }
  return 0;
}

C++: #include <iostream>
#include <stack>
using namespace std;

int main()
{
  stack<int> trains;
  int i;
  for (;;)
  {
    cin >> i;
    if (i != 0) trains.push(i);
    else
    {
      if (trains.empty()) break;
      cout << trains.top() << endl;
      trains.pop();
    }
  }
  return 0;
}

C++: #include<stdio.h>
int main(){
	int a,b,c,d,train[100];
	b=0;
	c=0;
	
	int g;
	int cont = 0;
	
	for(a=0;a<1000;a++){
		scanf("%d",&g);
		
		if(g != 0){
			train[cont] = g;
			cont++;
		}
		else{
			printf("%d\n",train[cont-1]);
			cont--;
		}
		
		if(cont == 0){
			break;
		}
		/*
		if(train[a]==0){
			c++;
		}else{
			b++;
		}
		if(b==c){
		break;
		} 
		*/
	}
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main() {
	int a;
	vector<int>l;
	while (cin >> a){
		if (a == 0){
			cout << l.back()<<endl;
			l.pop_back();
		}else{
			l.push_back(a);
		}
	}
}

C++: #include <iostream>
#include <stack>
#include <vector>
using namespace std;

int main(){
	int n;
	stack<int> t;
	vector<int> a;
	while(cin>>n){
		if(n==0){
			a.push_back(t.top());
			t.pop();
		}
		else{
			t.push(n);
		}
	}
	for(int i=0;i<a.size();i++){
		cout<<a[i]<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <stack>
#include <queue>

int main(){
	std::stack<int> in;
	std::queue<int> out;
	int num;
	
	while(std::cin >> num){
		if(num == 0){
			out.push(in.top());
			in.pop();
		}else
			in.push(num);
		
		//output
		if(in.empty()){
			while(!out.empty()){
				std::cout << out.front() << std::endl;
				out.pop();
			}
		}
	}
	
    return 0;
}

C++: #include <iostream>
#include <stack>
using namespace std;

int main()
{
	int num;
	stack<int> stack;
	
	while(cin >> num)
	{		
		
		if(num==0)
		{
			cout << stack.top() << endl;
			stack.pop();
		}
		else
		{
			stack.push(num);
		}
	}
	
	return 0;
}

C++: #include<iostream>
#include<utility>
using namespace std;

int main(){
	int a[100];
	int i = 0;

	for (int i = 0; i < 100; i++){
		a[i] = 0;
	}

	while (1){
		i++;
		cin >> a[i];
		if (a[i] == 0){
			int j = i+1;
			while (1){
				j--;
				if (a[j] != 0){
					cout << a[j] << endl;
					a[j] = 0;
					break;
				}
			}
		}
	}


	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
/* 変数名を被らせない
   デバッグコードを取り除く 
　　提出する問題を間違えない */
#define ANSWER(x) cout<<x<<endl
#define debug(x) cout<<#x<<": "<<x
int main(){
  stack<int> train;
  int a;
  while(1){
    cin >> a;
    if(a){
      train.push(a);
    }else{
      if(cin.eof())break;
      cout << train.top() << endl;
      train.pop();
    }
  }
}

C++: #include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<int> Car;
    int Size = 0;
    int number;
    vector<int> Order;

    while(cin >> number)
    {

            if(number != 0)
            {
                Car.push_back(number);
            }
            else if(number == 0)
            {

                Order.push_back(Car[(Car.size())-1]);
                Car.pop_back();

            }




    }
            for(int z = 0; z < Order.size(); z++)
        {
            cout << Order[z] << endl;
        }
}

C++: #include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  vector<int> train;

  while (cin >> n) {
    if (n) {
      train.push_back(n);
    }
    else {
      cout << train.back() << endl;
      train.pop_back();
    }
  }
  return 0;
}

C++: #include <iostream>
#include <stack>

using namespace std;

int main() {
    int n;
    stack<int> s;
    while (true) {
        cin >> n;
        if (cin.eof()) {
            return 0;
        }
        if (n == 0) {
            cout << s.top() << endl;
            s.pop();
        }
        else {
            s.push(n);
        }
    }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>
#include <stack>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
// BEGIN CUT HERE
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
// END CUT HERE

int main(){
  int in;
  stack<int> s;

  while(scanf("%d", &in) != EOF){
    if(in == 0){
      printf("%d\n",s.top());
      s.pop();
    }
    else s.push(in);
  }

  return 0;
}

C++: #include <iostream>
#include <stack>
using namespace std;
int main()
{
    stack<int>  stk;
    int         car;
    while (cin >> car) {
        if (car) {
            stk.push(car);
        } 
        else {
            cout << stk.top() << endl;
            stk.pop();
        }
    }
}

C++: #include<stack>
#include<iostream>

using namespace std;

main()
{
	int n;
	stack<int> st;
	
	while(cin >> n){
		if(n == 0){
			cout << st.top() << endl;
			st.pop();
		}
		else
			st.push(n);
	}
}

C++: #include<iostream>
#include<stack>
using namespace std;
int main(){
  int n;
  stack<int> car;
  while(cin >>n){
    if(!n){cout <<car.top()<<endl;car.pop();}
    else{car.push(n);}
  }
  return 0;
}

C++: #include<iostream>
#include<vector>

using namespace std;

int main(){
	vector<int> RailRoad, out;
	int buf;

	// 入力の終わりまで読み込み
	while(cin >> buf){
		if(buf == 0){
			buf = RailRoad[((int)RailRoad.size() - 1)];
			out.push_back(buf);
			RailRoad.pop_back();
		}else{
			RailRoad.push_back(buf);
		}
	}

	// イテレータの初期化
	for(vector<int>::iterator it = out.begin();it != out.end();++it){
		cout << *it << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <stack>

int main(){
    int n;
    std::stack<int> st;
    while(1){
        std::cin >> n;
        if(n == 0){
            std::cout << st.top() << std::endl;
            st.pop();
        }
        else
        {
            st.push(n);
        }
        if(std::cin.eof())
            break;
    }
}

C++: #include <stdio.h>
#include <string.h>

int st[10];

int main()
{
	int stn = 0;
	while(1)
	{
		int n;
		if(EOF == scanf("%d",&n))
		{
			break;
		}
		if(n == 0)
		{
			stn--;
			printf("%d\n",st[stn]);
		}
		else
		{
			st[stn] = n;
			stn++;
		}
	}
	return 0;
}