Go: package main

import "fmt"

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

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

int main() {
	int n, count = 0, a[10], i;
	stack<int> s;
	while (cin >> n,n>=0,!cin.eof()) {
		if (n > 0) s.push(n);
		else if (n == 0) { a[count++] = s.top(); s.pop(); }
	}
	for (i = 0; i < count; i++) {
		cout << a[i] << endl;
	}
}

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

int main(){
	int data[100]={0},i=0;
	std::stack<int> train;
	while(data[i] != EOF){
		scanf("%d",&data[i]);
		i++;
	}
	i=0;
	train.push(data[i]);
	i=1;
	while(data[i] != EOF){
		if(! train.empty()){
			if(data[i]==0){
				printf("%d\n",train.top());
				train.pop();
			}else{
				train.push(data[i]);
			}
		i++;
		}
	}
	return 0;
}

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

int main() {
  int tracks[10];
  int n;
  int p;

  p = 0;
  while (cin >> n) {
    if (n) {
      tracks[p++] = n;
    } else {
      cout << tracks[--p] << endl;
    }
  }

  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int main()
{
	vector<int> v;
	int n;
	while (cin >> n)
	{
		if (n != 0) v.push_back(n);
		else
		{
			cout << v.back() << endl;
			v.pop_back();
		}
	}
	return 0;
}

C++: #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 <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

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();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//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())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second.first
#define T4 second.second.second

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

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

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

int main(void){
	int n;
	vector<int> car;

	cin >> n;
	car.push_back(n);

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

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

C++: #include <cstdio>
#include <cstring>
#include <stack>

using namespace std;

int main()
{
  stack<int> s;
  int x;
  while(scanf("%d", &x) != -1){
    if(x)
      s.push(x);
    else
      printf("%d\n", s.top()), s.pop();
  }
  return 0;
}

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

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

int main() {
  int i;
  int cnt = 0;
  std::vector<int> vec;
  while(cnt != 45) {
    scanf("%d", &i);
    if(i == 0){
      printf("%d\n", vec.back());
      vec.pop_back();
    }else{
      vec.push_back(i);
    }
    cnt++;
  }
  return 0;
}

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

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

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

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

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
main(){
	int t[101],co=0;
	for(int i=0;i<=100;++i)t[i]=0;
	while(1){
		cin>>t[co];
		if(t[co]==0){
			--co;
			cout<<t[co]<<endl;
		}else ++co;
		if(co==0)break;
	}
}

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

int main(void){
  int input;

  std::stack<int> st;

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

  return 0;
}

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

int main(){
	int in[10],out[10];
	int in_num=0;
	int out_num=0;
	int n;
	while(cin >>n){
		if(n == 0){
			in_num--;
			out[out_num] = in[in_num];
			cout << out[out_num]<<endl;
			out_num++;
		}
		else {
			in[in_num] = n;
			in_num++;
		}
	}
	return 0;
}

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

C++: #include <iostream>
#include <stack>
   
int main(){
    std::stack<u_int> train;
    u_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 <iostream>
using namespace std;
int main(){
    int a[10];
    int n=0;
    while (!cin.eof()){
        int t;
        cin>>t;
        if (t) a[n++]=t;
        else if (n) cout<<a[--n]<<endl;
    }
    return 0;
}

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

using namespace std;

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

C++: #include <iostream>

using namespace std;

int main() {

	int i, j=0, n, a[10], b[10];

	for(i=0; i<10; i++) {
		b[i]=0;
	}

	i=0;
	while(1) {
		cin >> n;
		if(n==0) {
			b[j]=a[i-1];
			j++;
			i--;
			a[i]=n;
			if(i==0)
				break;
			continue;
		}
		a[i]=n;
		i++;
	}

	for(i=0; b[i]!=0; i++) {
		cout << b[i] << endl;
	}

	return 0;

}