Go: package main

import "fmt"

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

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

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

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

}

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

int main(){
	std::deque<int> que;
	int tmp;
	while(std::cin >> tmp){
		if(tmp == 0) std::cout << que.pop_back() << std::endl;
		else que.push_back(tmp);
	}
		return 0;
	}

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

using namespace std;       
int main(){
  stack<int> s;
  int a;
  while(cin >> a){
    if(a != 0){
      s.push(a);
    }else{
      cout << s.top();
      s.pop();
    }
    if(s.size() == 0)
      break;
  }
  return 0;
}

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

int main()
{
	int queue[100], input, i = 0;
	while (cin >> input) {
		if (input != 0) {
			queue[i] = input;
			++i;
		}
		else {
			--i;
			cout << queue[i] << endl;
			queue[i] = 0;
		}
	}
	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();
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int b[10000000];
int main(){
  int i=0,num,a[10],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 <algorithm>
#include <sstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int main()
{
	int x;
	stack<int> S;
	while (cin >> x && x != EOF) {
		if (x == 0) {
			cout << S.top() << endl; S.pop();
		}
		else {
			S.push(x);
		}
	}
}

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

int main() {
	int in;
	vector <int> a;
	while (1) {
		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>

int main()
{
        int s[10], p = 0;
        int i;
        while(std::cin >> i)
                if(i)
                        s[p++]=i;
                else
                        std::cout << s[--p] << std::endl;
        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 <cstdio>
#include <deque>

using namespace std;

int main(){
  deque<int> st;
  int n;
  while(~scanf("%d",&n)){
    if(n){
      st.push_back(n);
    }else{
      printf("%d\n",st.back());
      st.pop_back();
    }
  }
}

C++: #include <map>
#include <string>
#include <iostream>
#include <vector>
#include <set>
#include <cstdio>
#include <stack>
#include <algorithm>

using namespace std;

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

C++: #include <stdio.h>

int main(void){
	int i;
	int train[11]={0};
	int t,now=0,count=0;
	int car[11]={0};
	
	for(;;){
		scanf("%d",&t);
		if(t!=0){
			train[now]=t;
			now++;
		}
		else{
			now--;
			car[count]=train[now];
			train[now]=0;
			count++;
			if(now==0)break;
		}/*0
		printf("now=\n");
		for(i=0;i<10;i++){
			printf("car[%d] = %d\n",i,car[i]);
		}
		for(i=0;i<10;i++){
			printf("train[%d] = %d\n",i,train[i]);
		}
		*/
	}
	
	i=0;
	while(car[i]!=0){
		printf("%d\n",car[i]);
		i++;
	}
	
	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--;
}
}
}

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

using namespace std;

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

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

	return 0;
}

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

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


using namespace std;

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

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

using namespace std;

int main()
{
	stack<int> hako;
	int temp[100];
	int input[100];
	int t, i = 0, k = 0;
	
	
	while(cin>>t){
		input[i] = t;
		i++;
	}
	
	/*
	while(1){
		cin >> t;
		if( t == -1){
			break;
		}
		input[i] = t;
		i++;
	}
	*/
	for(int j = 0; j < i; j++){
		if(input[j] == 0){
			temp[k] = hako.top();
			hako.pop();
			k++;
		}
		else{
			hako.push(input[j]);
		}
	}
	
	for(int j = 0; j < k; j++){
		cout << temp[j] << endl;
	}
	
}

C++: #include <stack>
#include <iostream>
 
using namespace std;
 
int main(void){
        int tem;
        stack<int> st;
        cin >> tem;
        st.push(tem); 
        while(true){
                cin >> tem;
                if( cin.eof())
                        break;
                if(tem)
                        st.push(tem);
                else{
                        cout <<st.top()<<endl;
                        st.pop(); 
                }
        }
return 0;
}

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

stack<int> sta;

int main()
{
  int a;
  while(1){
    cin>>a;
    if(a)
      sta.push(a);
    else{
      cout<<sta.top()<<endl;
      sta.pop();
    }
  }
}

C++: #include <stdio.h>
 
int main(void) {
  std::stack<int> st;
  int n;
  while(scanf("%d", &n) != EOF) {
    if(n) st.push(n);
    else {
      printf("%d\n", st.top());
      st.pop();
    }
  }
  return 0;
}

C++: #include <stdio.h>

int main() {
	int temp[10];
	int input;

	int i = 0;
	
	while(scanf("%d", &input) != EOF) {
		if(input != 0) {
			temp[i] = input;
			i++;
		}

		else {
			i--;
			printf("%d\n", temp[i]);
		}
	}

	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a[10],i=0,n;
	while(scanf("%d",n)==1){
		if(n!=0){
			a[i]=n;
			i++;
		}
		else{
			i--;
			cout<<a[i]<<endl;
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
class stack{
	int row[10];
	int top;
	public:
		stack(){top = 0;}
		void push(int x);
		int pop();
};
void stack::push(int x){
	row[top] = x;
	top++;
}
int stack::pop(){
	top--;
	return row[top];
}
int main(){
	stack cars;
	int k;
	while(cin >>k){
		if(k == 0){cout<<cars.pop()<<endl;}
		else{cars.push(k);}
	}
	return 0;
}

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

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