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

using namespace std;

int main() {
    vector<int> buffers;
    int buffer;

    while(cin >> buffer) {
        if(buffer == 0){
            cout << buffers[buffers.size()-1] << endl;
            buffers.pop_back();
            continue;
        }

        buffers.emplace_back(buffer);
    }
}

C++: #include<stdio.h>
#include<stack>
#include<cstdio>

using namespace std;

int main(void){

	int inp;
	stack<int> train;

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

	return 0;
}

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

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

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



int main(){
  int num;
  stack<int> st;
  cin>>num;
  st.push(num);
  while(st.size()!=0){
    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()
{
	int num;
	stack<int> st;
	
	while(!cin.eof())
	{
		cin >> num;
		
		
		if(num==0)
		{
			cout << stack.top() << endl;
			st.pop();
		}
		else
		{
			st.push(num);
		}
	}
	
	return 0;
}

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

int main()
{
  std::stack<int> train;
  int num;
  while(std::cin >> num){
    if(num != 0){
	  train.push( num );
	}
	else {
	  std::cout << train.top() << std::endl;
      train.pop();
    }
  }
  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);
	
	while(!s.empty()){
		int a;
		cin >> a;
		if(a == 0){
			cout << s.top() << endl;
			s.pop();
		}
		else {
			s.push(a);
		}
	}
	
	return 0;
}

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

int main() {
int k=0,b;
int a[1];
while(cin>>b){
	if(b!=0){
		a[k]=b;
		k=k+1;
	}
	if(b==0){
		cout<<a[k-1]<<endl;
		k=k-1;
	
}
}
	return 0;
}

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

using namespace std;

int main(){

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


	return 0;
}

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

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

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int train[10],moving,situation=0,ans[10],n=0,ende=0;
    while(1){
        cin>>moving;
        if(moving!=0){
            train[situation]=moving;
            situation++;
        }
        else {
                situation--;
                ans[ende]=train[situation];
                ende++;
        }
        if(situation==0)break;
    }
    for(int i=0;i<ende;i++)cout<<ans[i]<<endl;

}

C++: /*****include*****/
#include <iostream>
#include <list>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****変数置き場*****/
	list<int> V;
	int order;
	/*****処理部*****/
	while(1){
		cin >> order;
		if(order == 0){
			cout << V.back() << endl;
			V.pop_back();
		}else{
			V.push_back(order);
		}
	}
	return 0;
}

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

int main()
{
	int n = 0;
	stack<int>s;
	bool flag = false; 

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

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

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

using namespace std;

int main() {

	stack<int> st;
	int a, ans[100]={0},i = 0;

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

	
	return 0;
}

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

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

int main() {
	int n, count = 0, a[11], i;
	stack<int> s;
	while (cin >> n,n>=0,!cin.eof()) {
		if (n > 0) s.push(n);
		else if (n == 0) {
			a[count++] = s.top();
			s.pop();
		}
	}
	for (i = 0; i < count; i++) {
		cout << a[i] << endl;
	}
}

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

using namespace std;

void solve()
{
	stack<int> Stack;
	int Input;
	while(cin >> Input)
	{
		if(Input)
		{
			Stack.push(Input);
		}
		else
		{
			cout << Stack.top() << endl;
			Stack.pop();
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl



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

C++: #include<stdio.h>

int	i	=	0,	result;
int	train[100];

void	push(int	k){
	train[i]	=	k;
	i++;
}

void	pop(int train[]){
	int	a,	check	=	0;
	for(a	=	i	-	1;	a	>=	0;	a--){
		if(train[a]	!=	0){
			result	=	train[a];
			train[a]	=	0;
			check	+=	1;
		}
		if(check	!=	0)break;
	}
}


int	main(){
	int	k;
	while(1){
		scanf("%d",	&k);
		push(k);
		if(k	==	0){
			pop(train);
			i	-=	2;
			printf("%d\n",	result);
		}
		if(i	==	0)break;
	}
}

C++: #include <stdio.h>

#include <string.h>

#include <stack>

#include <iostream>


using namespace std;

int main(){
    
    int input;
    stack<int> train;
    for (;;) {
        scanf("%d",&input);
        if (input!=0)train.push(input);
        else {
            printf("%d",train.top());
            train.pop();
        }
    }
}
    //        if(strcmp(c,pu) == 0){
    //
    //            scanf("%s",&color);
    //
    //            st.push(color);
    //
    //        }
    //
    //        if(strcmp(c,po) == 0){
    //
    //            cout<<st.top()<<endl;
    //
    //            st.pop();
    //
    //        }
    //
    //        if(strcmp(c,qu) == 0){
    //
    //            return 0;
    //
    //        }
    //
    //    }
    
    //}