Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	n, err := strconv.Atoi(nextString())
	return n, err
}

func main() {
	scanner.Split(bufio.ScanWords)

	stack := []int{}
	for {
		n, err := nextInt()
		if err != nil {
			break
		}

		if n == 0 { // pop
			fmt.Println(stack[len(stack)-1])
			stack = stack[0:(len(stack) - 1)]
		} else { // push
			stack = append(stack, n)
		}
	}
}

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

using namespace std;

int main()
{
	vector<int> train;
	int a;
	vector<int>::iterator it;
	for(;cin >> a;)
	{
		if(a!=0)
			train.push_back(a);
		else
		{
			it=train.end()-1;
			cout << *it << endl;
			train.pop_back();
		}
	}
}

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

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];
			out_num++;
		}
		else {
			in[in_num] = n;
			in_num++;
		}
	}
	for(int i=0;i<out_num;i++)
		cout <<out[i]<<endl;
		
	return 0;
}

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

int main(){

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

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
    int a,i;
    vector<int> s;
    vector<int> t;
    while(cin>>a){
        if(a!=0){
            s.push_back(a);
        }else{
            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 <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<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<bits/stdc++.h>
using namespace std;
int main(){
  stack<int> a;
  int box;
  while(1){
    cin >> box;
    if(box){
      a.push(box);
    }else{
      cout << a.top() << endl;
      a.pop();
    }
    if(cin.eof())break;
  }
}

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

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

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()
{
	int num;
	stack<int> st;
	
	while(!cin.eof())
	{
		cin >> num;
		
		
		if(num==0)
		{
			cout << st.top() << endl;
			st.pop();
		}
		else
		{
			st.push(num);
		}
	}
	
	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<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

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

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

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    stack<int> stk;
    for(;;){
        int n;
        if(!(cin >> n))
            return 0;

        if(n == 0){
            cout << stk.top() << endl;
            stk.pop();
        }else{
            stk.push(n);
        }
    }
}

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

int main() {
	int in;
	vector <int> a;
	while (cin >> in;) {
		if (in == 0) {
			cout << a.back();
			a.pop_back();
			/*if (a.size() == 0)
				break;
			else*/
				cout << endl;
		}
		else
			a.push_back(in);
	}
	return 0;
}

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

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

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

int main(int argc,char* argv[]){
  std::vector<int> vec(1000);
  
  while(!std::cin.eof()){
    int temp;
    std::cin >> temp;
    if(temp == 0){
      std::cout << vec.back() << std::endl;
      vec.pop_back();
      continue;
    }else{
      vec.push_back(temp);
      continue;
    }
  }

  return 0;
  
}

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

using namespace std;

int number[100];
int car;
int position = 0;

int main(){
	while(cin >> car){
		if(car > 0){
			number[position] = car;
			position++;
		}else{
			position--;
			cout << number[position] << endl;
		}
	}
}

C++: 
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	vector<int> train;
	int a;
	do {
		cin >> a;
		if (a == 0) {
			cout << train.back() << endl;
			train.pop_back();
		}
		else {
			train.emplace_back(a);
		}
	} while (train.size()!=0); 
	return 0;
}