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<iostream>
#include<string>
using namespace std;

int main(){
    int n;
    int i=0;
    int s=55;
    int num[105];
    while(cin>>n){
        if(n==0){
            while(1){
                if(num[s]!=0){
                    cout<<num[s]<<endl;
                    num[s]=0;
                    s=55;
                    break;
                }
                s--;
            }

        }
        else {
            while(1){
                if(num[i]==0){
                    num[i]=n;
                    i=0;
                    break;
                }
                i++;
            }
        }
                }
    return 0;
    }

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

int main(){
	
	int no;

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

	return 0;
}

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


stack<int> S;
int N;

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

	return 0;
}

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

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

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

  cin >> n;
  s.push(n);

  while(s.size() != 0) {
    cin >> n;
    if(!n) {
      cout << s.top() << endl;
      s.pop();
    }
    else s.push(n);
  }
}

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

int main()
{
    vector<int> entered_cars;
    int number;

    while (cin >> number)
    {
        if(number == 0)
        {
            int& x = entered_cars.back();
            cout << x << endl;
            entered_cars.pop_back(); 
        }
        else
        {
            entered_cars.push_back(number);
        }
    }

    return 0;
}

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

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

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

using namespace std;


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

}

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

using namespace std;

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

C++: #include<iostream>
using namespace std;
int main(){
  int i=0,num,a[10],x=0;
  
  while(cin>>num){
    if(num==0)cout<<a[--i]<<endl;
    else  a[i++]=num;
  } 
  return 0;
}

C++: #include<iostream>
using namespace std;
 
int main(){
	int vehicle[10] = {}, count = 0, n;
	while(cin >> n){
		if(n != 0)
			vehicle[count++] = n;
		else
			cout << vehicle[--count] << endl;
	}
	return 0;
}

C++: #include <stack>
#include <iostream>
 
using namespace std;
 
int main(void){
        int tem;
        stack<int> st;
        cin >> tem;
        st.push(tem); 
        while(true){
                if( cin.eof())
                        break;
                cin >> tem;
                if(tem)
                        st.push(tem);
                else{
                        cout <<st.top()<<endl;
                        st.pop(); 
                }
        }
return 0;
}

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

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

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

C++: #include<iostream>
#include<stack>
using namespace std;
int main(void){
	int num;
	stack<int> st;

	while(cin>>num){
		st.push(num);
		if(num==0){
			st.pop();//0ツづーツ渉慊つュ
			cout<<st.top()<<endl;
			st.pop();
		}
	}
	return 0;
}

C++: #include<cstdio>

int main(){
	int g[10];
	int i = 0;
	int t;
	while(scanf("%d", &t) + 1){
		if(t){
			g[i] = t;
			i++;
		}else{
			i--;
			printf("%d\n", g[i]);
		}
	}
	return 0;
}

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

int main(){
	stack<int> st;
	int n, a;

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

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

int main(){
	std::stack<int> switching_rail;
	std::queue<int> out_number;
	int in_number;
	//Input
	while(std::cin >> in_number){
		if(in_number == 0){
			out_number.push(switching_rail.top());
			switching_rail.pop();
		}else{
			switching_rail.push(in_number);
		}
	}
	//Output
	while(!out_number.empty()){
		std::cout << out_number.front() << std::endl;
		out_number.pop();
	}
	return 0;
}

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

using namespace std;
int main(int argc, char const* argv[])
{
	stack<int> data;
	int n;

	while( cin >> n ){
		if( n != 0 ) data.push( n );
		else{
			cout << data.top() << endl;
			data.pop();
		}
	}
	return 0;
}