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 <array>

std::array<u_int, 100> stack;
int point=0;

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

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

int main(){
	int num;

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

    return 0;
}

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

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

using namespace std;

int str1[100],str2[100],mo;

int  s=1,t1,t2;

int main(){


    while(scanf("%d",&mo) != EOF){


    if(mo!=0){
        str1[t1]=mo;
        t1++;

    }else {
        str2[t2++]=str1[--t1];

    }

    if(t1==0)break;

    }

    for(int i=0;i<100;i++){

            if(str2[i]==0)break;
        cout << str2[i] << endl;
    }


return 0;
}

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

using namespace std;

int main(void) {

	/*
	double x[3] = { 0,0,0 };
	double y[3] = { 0,0,0 };
	double xp = 0, yp = 0;
	int flag[3] = { 0,0,0 };

	while (cin >> x[0]>> y[0]>> x[1]>> y[1]>> x[2]>> y[2]>> xp>> yp) {
		for (int i = 0; i < 3; i++) {
			int temp1 = (i + 1) % 3;
			int temp2 = (i + 2) % 3;
			double checkI = (y[temp1] - y[i]) * (x[temp2] - x[i]) - (x[temp1] - x[i]) * (y[temp2] - y[i]);
			double checkP = (y[temp1] - y[i]) * (xp - x[i]) - (x[temp1] - x[i]) * (yp - y[i]);

			if (checkI * checkP > 0) {
				flag[i] = 1;
			}
		}
		if (flag[0] == 1 && flag[1] == 1 && flag[2] == 1) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
		flag[0] = 0;
		flag[1] = 0;
		flag[2] = 0;
	}
	*/
	int input_num;
	vector<int> train_num;
	while (cin >> input_num) {
		if (input_num == 0) {
			cout << train_num.back() << endl;
			train_num.pop_back();
		}
		else if (input_num >= 1 && input_num <= 10) {
			train_num.push_back(input_num);
		}
	}

	return 0;
}

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

stack<int> car;

int main()
{
	int n;
	while(scanf("%d",&n) != EOF) {
		if(n != 0) {
			car.push(n);
		} else {
			printf("%d\n",car.top());
			car.pop();
		}
	}	
	return 0;
}

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

using namespace std;

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

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

int main(){
	stack<int> s;
	int a;
	while	( scanf(" %d", &a) != EOF ){
		if(a==0) {
			cout << s.top() << endl;
			s.pop();
		}
		else s.push(a);
	}
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

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 <stack>
#include <iostream>

int main(){
        using namespace std;

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

C++: #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <stack>

using namespace std;

stack<int> s;

int main(void){
	while (true){
		int n;
		scanf("%d", &n);
		if (n != 0) s.push(n);
		else if (n == 0) {
			cout << s.top() << endl;
			s.pop();
		}
		if (s.empty()) break;
	}
}

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

template <typename TYPE>
class my_stack{
public:
	my_stack(){};
	void push(TYPE x){
		vec.push_back(x);
		return;
	};
	TYPE pop(){
		TYPE x = vec.back();
		vec.pop_back();
		return x;
	};

private:
	vector<TYPE> vec;
};

int main()
{
	my_stack<int> stack;
	int n;
	while (cin >> n){
		if (n) stack.push(n);
		else cout << stack.pop() << "\n";
	}
	cout << flush;
}

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

using namespace std;

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

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

C++: #include <stdio.h>
#include <stack>
using namespace std;

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

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

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

int main() {
	int x;
	deque<int> st;
	while (cin >> x) {
		if (x == 0) {
			cout << st.back() << endl;
			st.pop_back();
		}
		else {
			st.push_back(x);
		}
	}
	return 0;
}

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

int main()
{
    int n;
    int stack[10];
    int index=0;
    vector<int> r;
    while (scanf("%d",&n) != EOF)
    {
	if (n!=0)
	{
	    stack[index] = n;
	    index++;
	} else {
	    r.push_back(stack[index-1]);
	    index--;
	}
    }
    for (int i=0; i<r.size(); i++)
    {
	cout << r[i] << endl;
    }
    return 0;
}

C++: #include<stdio.h>

int main(){
	int car[10]={0,0,0,0,0,0,0,0,0,0};
	int a,c=0;
	
	while(~scanf("%d",&a)){
		if(a==0){
			c--;
			printf("%d",car[c]);
		}
		else {
			car[c]=a;
			c++;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
int main(){
    vector<int> array;
    int i = -1;
    while(cin >> i){
        if(i == 0){
            cout << array[array.size()-1]<< endl;
            array.pop_back();
        }else 
            array.push_back(i);
    }
    return 0;
}

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

using namespace std;

stack<int>s;

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

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

int main()
{
    int train[10]={0},n,count=0,outTrain[10],trainCount=0;
    while(scanf("%d",&n)!=EOF){
        if(n){
            for(int i=count ; i!=0 ; i--){
                train[i]=train[i-1];
            }
            train[0]=n;
            count++;
        }
        else{
            outTrain[trainCount]=train[0];
            for(int i=0 ; i<count ; i++){
                train[i]=train[i+1];
            }
            train[count]=0;
            count--;
            trainCount++;
        }
    }
    for(int i=0 ; i<trainCount ; i++){
        cout << outTrain[i] << '\n';
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(i=l;i<n;i++)
using namespace std;

int main(){
	int data[15]={},i=0,n;

	while(scanf("%d",&n)!=EOF){
		if(n!=0){
			data[i]=n;
			i++;
		}else if(n==0){
			cout<<data[i-1]<<endl;
			i--;
		}
	}
}

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;
	while (true) {
		cin >> a;
		if (a == 0) {
			cout << train.back() << endl;
			train.pop_back();
		}
		else {
			train.emplace_back(a);
		}
	}
	return 0;
}