Go: package main

import "fmt"

func main() {
	var i int
	stack := make([]int, 0)
	for {
		v, _ := fmt.Scan(&i)
		// fmt.Println(stack)
		// println(v)
		if v == 0 {
			break
		}
		if i == 0 {
			fmt.Println(stack[len(stack)-1])
			stack = stack[:len(stack)-1]
			continue
		}
		stack = append(stack, i)
	}
}

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

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

C++: #include <stdio.h>

#define N 10
int main(void){
    int stk[N], sp=0;
    int n;
   
    for (int i=0; i<N; i++) stk[i]=0;
	
	while (scanf("%d", &n)){
	    if (n==0){
		    printf("%d\n", stk[--sp]);
		} else {
		    stk[sp++] = n;
		}
	}
    return 0;
}

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

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

C++: #include <stdio.h>
#include <stack>
int main(void)
{
    using namespace std;
    stack<int> stk;
    int n;
    while(scanf("%d",&n)==1)
    {
        if(!n)
        {
            printf("%d\n",stk.top());
            stk.pop();
        }
        else
        {
            stk.push(n);
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
    stack<int> st;

    int a;

    cin >> a;
    st.push(a);

    while (st.size()) {
        cin >> a;
        if (a) st.push(a);
        else { cout << st.top() << endl; st.pop(); }
    }
}

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

int a[11], b, t;

int main() {
  cin>>a[0];
  t=1;
  
  while(cin>>b) {
    if(b>0) {
      a[t]=b;
      t++;
    }else {
      cout<<a[t-1]<<endl;
      t--;
    }
  }
  
  return 0;
}

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

C++: #include <cstdio>

int stack[10] = { -1 };
int size = 0;

void add(int n){
    stack[size] = n;
    size++;
}

void dec(){
    size--;
    printf("%d\n", stack[size]);
    stack[size] = -1;
}

int main(){
    int n;
    
    scanf("%d", &n);
    add(n);
    while(size != 0){
        scanf("%d", &n);
        if(n == 0){
            dec();
        }else {
            add(n);
        }
    }

    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int tmp = 0;
	deque<int>A;
	while (cin >> tmp) {
		if (tmp == 0) {
			cout << A.front() << endl;
			A.pop_front();
		}
		else {
			A.push_front(tmp);
		}
	}
}

C++: /* 0013.c */
#include<stdio.h>
 
 
int main(void)
{
    int num, top;
    int train[1024];
    int i;
 
    top = 0;
 
    while (scanf("%d", &num) != EOF){
        if (num == 0){
            printf("%d\n", train[top - 1]);
            train[top - 1] = 0;
            top--;
        }
        else { 
            train[top] = num;
            top++;
        }
    }
 
    return 0;
}

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

int main()
{
  int n, i = 0, j = 0;
  int car[10] = {1};
  int output[10];
  while(cin >> n){
    if(n == 0){
      output[j] = car[i - 1];
      car[i - 1] = 0;
      i--;
      j++;
      if(car[0] == 0)
	break;
    }else{
      car[i] = n;
      i++;
    }
  }
  for(int i = 0; i < j; i++){
    cout << output[i] << endl;
  }
}

C++: #include <bits/stdc++.h>
#include <vector>
using namespace std;
int x, lol;
vector<int> vec;

int main(){
	lol = 0;
	while(cin >> x){
		if(x == 0){
			cout << vec[lol-1] << "\n";
			vec.erase(vec.begin()+(lol-1));
			lol--;
		}
		else{
			vec.push_back(x);
			lol++;
		}
	}
	
	
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

stack<int> cars;

int main() {
	int input = -1;

	cin >> input;
	while (input != -1) {
		if (input > 0) {
			cars.push(input);
		} else {
			cout << cars.top() << endl;
			cars.pop();
		}

		input = -1;
		cin >> input;
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

C++: #include <iostream>

using namespace std;

int main(){
    int track[10], c, num;
    while(1){
        cin >> num;
        if(!num){
            if(!c) break;
            else cout << track[c--] <<endl;
        }
        else{
            if(c==10) cout << "Already Full" <<endl;
            else track[++c] = num;
        }
    }
    return 0;
}

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

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

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

using namespace std;

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

    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
    int a,c,i;
    vector<int> s;
    vector<int> t;
    while(cin>>a){
        c=s.size();
        if(a!=0){
            s.push_back(a);
        }
        else if(a==0&&c>0){
            s.pop_back();
            t.push_back(s[s.size()-1]);
            s.pop_back();
        }
    }
    int b=t.size();
    for(i=0;i<b;i++){
        cout << t[i] << endl;
    }
    return 0;
}

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

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

	while (1)
	{
		cin >> n;
		if (n == 0)
		{
			ans.push_front(s.top());
			s.pop();
			if (s.empty()) break;
		}
		else
		{
			s.push(n);
		}
	}

	while (1)
	{
		if (!ans.empty())
		{
			cout << ans.back() << endl;
			ans.pop_back();
		}
		else break;
	}
	return 0;
}

C++: #include<stdio.h>

int main(){
  int i = 0, x;
  int data[100];
  scanf("%d", &x);
  while(x != EOF){
    scanf("%d", &x);
    if(x != 0){
      data[i] = x;
      i++;
    }else{
      printf("%d\n", data[i-1]);
      i--;
    }
  }
  return 0;
}