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 <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <sstream>
#include <cstdlib>
#include <cmath>
 
using namespace std;

int main(){
    int n;
    int stack[10] = {0};
    int index = 0;
    while(cin >> n){
        switch(n){
            case 0 : {
                index--;
                cout << stack[index] << endl;
                break;
            }
            default : {
                stack[index] = n;
                index++;
                break;
            }
        }
    }
    return 0;
}

C++: //include---------------------------------------------------------------------------
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cctype>
#include<ccomplex>
#include<vector>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<bitset>
#include<map>
#include<algorithm>


//using namespace-------------------------------------------------------------------
using namespace std;

//define,const----------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < n; i++){
const int INF = 1 << 25;

//global----------------------------------------------------------------------------
stack<int> cars;
int numbar;

//function--------------------------------------------------------------------------
int main(){
	while(scanf("%d", &numbar) != EOF){
		if(numbar == 0){
			printf("%d\n", cars.top());
			cars.pop();
			continue;
		}
		cars.push(numbar);
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <stack>
using namespace std;
int main(void) {
  int num;
  stack<int> s;
  while(cin >> num) {
    if(num != 0) s.push(num);
    else { printf("%d\n", s.top()); s.pop(); }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

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

using namespace std;

int main()
{
	stack<int> s;

	vector<int> Ans;

	int temp;

	while (true)
	{
		cin >> temp;

		if (temp != 0)
		{
			s.push(temp);
		}
		else
		{
			Ans.push_back(s.top());

			s.pop();
		}

		if (s.empty())
		{
			break;
		}
	}

	for (vector<int>::size_type i = 0; i < Ans.size(); i++)
	{
		cout << Ans[i] << endl;
	}

	return 0;
}

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

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

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

int main(){
	std::vector<int> rail;
	std::vector<int> out;
	int a;

	while(std::cin >> a){
		if(a != 0){
			rail.push_back(a);
		}else if(a == 0){
			out.push_back(rail.back());
			rail.pop_back();
		}else{
			break;
		}
	}

	for(int i=0; i<(int)out.size(); ++i){
		std::cout << out.at(i) << std::endl;
	}
}

C++: #include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    int car[105];
    int num;
    int i=0;
    while(1){
        cin>>num;
        if(num!=0){
            car[i]=num;
            i++;}
        else{
            i--;
            cout<<car[i]<<endl;
            car[i]=0;
        }
    }
    return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	
	stack<int> s;
	s.push(n);
	
	int a;
	cin >> a;
	if(a == 0){
		cout << s.top() << endl;
		s.pop();
	}
	else {
		s.push(a);
	}
	
	return 0;
}

C++: #include <iostream>
#include <stack>
using namespace std;
 
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 <iostream>
#include <stack>
using namespace std;

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

C++: #include<iostream>
using namespace std;
int main(){
int a[]={0,0,0,0,0,0,0,0,0,0};
int b;
while(cin>>b){
if(b==0){
cout<<a[0];
for(int i=0;i<9;i++){
a[i]=a[i+1];}}
else{
for(int i=0;i<9;i++){
a[9-i]=a[8-i];}
a[0]=b;}}

C++: #include <iostream>

using namespace std;

typedef struct Stack {
        int array[100];
        int top;

        Stack()
                :top(0)
        {
                for (int i = 0; i < 100; i++) {
                        array[i] = 0;
                }
        }
} Stack;

int main()
{
        Stack stack;
        int car;

        while (cin >> car) {
                if (car) {
                        stack.array[stack.top++] = car;
                } else {
                        printf("%d\n", stack.array[--stack.top]);
                        stack.array[stack.top] = 0;
                }
        }

        return 0;
}

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

using namespace std;

int main(void){
	int tmp;
	stack<int> st;
	vector<int> vehicles;

	while (cin >> tmp){
		if (tmp != 0){
			st.push(tmp);
		}
		else{
			if (st.empty() == false){
				vehicles.push_back(st.top());
				//cout << st.top() << endl;
				st.pop();
			}
		}
	}

	vector<int>::iterator it = vehicles.begin();
	while (it != vehicles.end()){
		cout << *it << endl;
		++it;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main()
{
    vector<int>a;
	int b;
	while(cin >> b){
		if(b==0){
			printf("%d\n",a[a.size()-1]);
			a.pop_back();
		}
		else{
			a.push_back(b);
		}
	}
    return 0;
}

C++: #include <stdio.h>

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

C++: #include<stdio.h>
int main(){
  int n,m,i=0,j=0,h=0;
  int data[20];
  int str[10]={0};
  while(scanf("%d",&n)!=EOF){
    data[i]=n;
    if(n==0){
      j=i;
      while(data[i-1]==0){
	i--;
      }
      str[h]=data[i-1];
      data[i-1]=0;
      i=j;
      j=0;
      h++;
    }
    i++;
  }
  for(i=0;i<h;i++){
    printf("%d\n",str[i]);
  }
  return(0);
}

C++: #include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <stack>
#include <cstring>

using namespace std;

int main(){
	stack<int> garage;
	vector<int> out;
	int enter;
	cin >> enter;
	garage.push(enter);
	while(!garage.empty()){
		cin >> enter;
		if(enter == 0){
			out.push_back(garage.top());
			garage.pop();
		}
		else{
			garage.push(enter);
		}
	}

	for(vector<int>::iterator it = out.begin(); it != out.end(); it++){
		cout << *it << endl; 
	}

	return 0;
}

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