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 <stdio.h>

int train(int array[], int a)
{
	int i;
	for(i=0; i<10; i++)
	{
		if(array[i]==0)
		{
			if(a)
			{
				array[i]=a;
				return 0;
			}
			
			if(i>0 && a==0)
			{
				printf("%d\n", array[i-1]);
				array[i-1]=0;
				return 0;
			}
		}
	}
	return 0;
}
	

int main (void)
{
	int a, trains[10], i;
	
	for(i=0; i<10; i++)
	{
		trains[i]=0;
	}
	
	while(scanf("%d", &a)!=EOF)
	{
		train(trains, a);
	}
	
	return 0;
}

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

using namespace std;

int main()
{
	stack<int> trains;
	int n, c, i;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &c);
		if (c == 0)
		{
			printf("%d\n", trains.top());
			trains.pop();
		}
		else
			trains.push(c);
	}
	return 0;
}

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

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

C++: #include <stack>

int main(){
  std::stack<int>s;
  for(int x;~scanf("%d",&x);)
    if(x)s.push(x);
    else printf("%d\n",s.top()),s.pop();
}

C++: #include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  2000000000
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d); BR;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    int s[100], top = 0, a;
    while(cin >> a){
        if(a){
            s[top++] = a;
        }else{
            OUTL(s[--top]);
        }
    }
RET;}

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

int main(){
	int stack[10];
	int s_num = 0;
	int x;

	while(cin >> x){
		if(x == 0){
			cout << stack[s_num-1] << endl;
			s_num --;
		}else{
			stack[s_num] = x;
			s_num ++;
		}
	}

	return(0);
}

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

using namespace std;
int n;
int a[10];
int i = 0;

int main()
{
	stack<int> s;
	while(scanf("%d", &n) != EOF){
		if(n == 0){
			a[i] = s.top();
			s.pop();
			i++;
		}
		else{
			s.push(n);
		}
	}
	
	for(int j = 0; j < i; j++){
		printf("%d\n", a[j]);
	}
	
	return 0;
}

C++: #include　<iostream>

int stack[100];
int point=0;

void push(int p){
	stack[point]=0;
	++point;
}

void pop(){
	std:cout << stack[point] << endl;
	--point;
}

int main(){
	int num;

	for(int i=0;i<100;i++){
		std:cin >> num;
		if(num==0) pop();
		else push(num);
	}

    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++;
    }else{
      car[i] = n;
      i++;
    }
  }
  for(int i = 0; i < j; i++){
    cout << output[i] << endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <stack>
using namespace std;
int main() {
  stack<int> s;
  vector<int> v;
  int n;
  while (cin >> n) {
    if (n == 0 && !s.empty()) {
      v.push_back(s.top());
      s.pop();
    } else {
      s.push(n);
    }
  }
  for (int i = 0; i < v.size(); ++i) {
    cout << v[i] << endl;
  }
  return 0;
}

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

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

  return 0;
}

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

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

C++: #include<iostream>
#include<vector>
#include<string>
#include<math.h>
using namespace std;

int main()
{
	vector<int>a;
	vector<int>b;
	vector<int>c;
	int s[20];

for(int i=0;i<20;i++)
{
	cin>>s[i];

if(s[i]==0)
	{
		b.push_back(s[i]);
		a.push_back(c.back());
		c.pop_back();
		if(c.size()==0)
		{
		break;
		}
	}
	else
	{
		c.push_back(s[i]);
	}
	
}
for(int j=0;j<a.size();j++)cout<<a[j]<<endl;
return 0;


}

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

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

using namespace std;

int main()
{
	deque<int> st;
	int n;
	while(cin >>n){
		if(n){
			st.push_back(n);
		}else{ // 0が入力されたとき
			cout << st.back() << endl;
			st.pop_back();
		}
	}
	return 0;
}

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

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

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

int main()
{
	int line,i=0,stack[10] = {0};

	while(cin >> line)
	{
		if(line == 0)
		{
			i--;
			cout << stack[i] << endl;
		}
		else
		{
			stack[i] = line;
			i++;
		}
	}

	return 0;
}

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() {
  stack<int> s;
  int n;
  while(cin>>n) {
    if(n==0){
      cout<<s.top()<<endl;
      s.pop();
    }
    else
      s.push(n);
  }
  return 0;
}

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

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

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

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

int main(){
	int rail[11];
	int num=0;
	while(true){
		int now;
		cin >> now;
		if(cin.eof())
			break;
		else if(now ==0){
			cout << rail[num] << endl;
			num--;
		}
		else{
			num++;
			rail[num] = now;
		}
	
	}
	return 0;

}

C++: #include<stdio.h>
int main(){
int a[100];
int j;
for(int i=0;;i++){
scanf("%d",&a[i]);
if(a[i]==0){
j=i;
while(){
if(j1!=0){
printf("%d",a[j1]);
break;
}
j--;
}
}
}