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

int main(int argc,char* argv[]){
  std::stack<int> vec;
  
  while(!std::cin.eof()){
    int temp;
    std::cin >> temp;
    if(temp == 0){
      std::cout << vec.top() << std::endl;
      vec.pop();
      continue;
    }else{
      vec.push(temp);
      continue;
    }
  }

  return 0;
  
}

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

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

int main(){
    u_int a, end = 0;
    std :: vector<int> v = {};
    while(std :: cin >> a){
        if(a == 0){
            std :: cout << v.at(end-1) << std :: endl;
            v.pop_back();
            end--;
        } else{
            v.push_back(a);
            end++;
        }
    }
}

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

int main(void){
  stack<int> data;
  int a;

  while(scanf("%d",&a) != EOF){
    if(a) data.push(a);
    else {
      if(data.empty()) break;
      printf("%d\n",data.top());
      data.pop();
    }
  }

  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(void)
{
    vector<int> t;
    int a;
    while (true)
    {
        cin >> a;
        if (a != 0)
        {
            t.push_back(a);
        }
        else if (a == 0)
        {
            cout << t.back() << endl;
            t.pop_back();
        }
        if (t.empty())
        {
            break;
        }
    }
}

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

using namespace std;

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

C++: /*
車両の出入り。
入力された番号の車両が格納されていき、0が入力されたときは、
最後に格納した（1番手前にある）車両の番号を表示し、出発させる。
*/

#include <iostream>
using namespace std;

int main(void) {
    int garage[100] = {};
    int size;
    int i = 0;
    int number;
    
    while(cin >> number) {
        if(number == 0) {
            i--;
            if(i < 0) {
                break;
            }
            cout << garage[i] << endl;
        } else {
            garage[i] = number;
            i++;
        }
    }
}

C++: #define scanf_s scanf
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 100
int main(void)
{
	int w, n, now = 0;
	int list[MAX] = { 0 };
	do{	
		scanf_s("%d", &n);
		if (n != 0) { list[now] = n; ++now; }
		else { --now; printf("%d\n", list[now]); }
	} while (now != 0);
}

C++: #include<bits/stdc++.h>
using namespace std;

string str1[11],str2[11],mo;

int  s=1,t1,t2;

int main(){


    while(1){

    cin >> mo;


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

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

    }

    if(t1==0)break;

    }

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

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


return 0;
}

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

int main(){
	long long int num;
	stack<int> s;
	cin >> num;
	if(num!=0){
		s.push(num);
	}
	while(!s.empty()){
		cin >> num;
		if(num!=0){
			s.push(num);
		}
		else{
			cout << s.top() << endl;
			s.pop();
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include<string>
using namespace std;
int top,s[105];
void push(int x){
    s[++top]=x;
}
void pop(){
    top--;
    cout<<s[top+1]<<endl;
}
int main(){
    int num;
    while(1){
        cin>>num;
        if(num==0)
            pop();
        else push(num);
    }
    return 0;
}

C++: #include <stdio.h>

int main()
{
int p[11]={};
int x,i;
i=0;x=0;
while(scanf("%d",&x)!=EOF)
{
if(x>0){p[i]=x;i++;}
else{i--;printf("%d\n",p[i]);}

}
return 0;
}

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

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

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

int main()
{
	int train[100000]={};
	long int i=0;
	while(1){
		cin>>train[i];
		if(train[i]==0){
			i--;
			cout<<train[i]<<endl;
		}else{
			i++;
		}
		if(i==0) break;
	}
}

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

int main(){                                                                                 
  std::stack<int> st;                                                                       
  int input;                                                                                
  while(std::cin >> input ){                                                                
    if(input == 0){                                                                         
      std::cout << st.top() << std::endl;                                                   
      st.pop();                                                                             
    }                                                                                       
    else{                                                                                   
      st.push(input);                                                                       
    }                                                                                       
  }                                                                                         
  return 0;                                                                                 
}

C++: #include<iostream>
#include<stack>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

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

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

int main(){

	std::stack<int> train;

	int buf;

	while(std::cin >> buf){

		if(buf == 0){

			std::cout << train.top() << endl;
			train.pop();

		}else{

			train.push(buf);

		}
	
	}

	return 0;
}

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

using namespace std;

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

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

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

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

int main() {
  int n;
  stack<int> stack;
  vector<int> v;
  while(cin >> n) {
    if(n == 0) {
      v.push_back(stack.top());
      stack.pop();
    } else {
      stack.push(n);
    }
  }

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

  return 0;
}

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

int main(){
	std::vector<int> out;
	std::vector<int> stock;
	int a;
	while( std::cin >> a ){
		if( a == 0 ){
			out.push_back(stock.back());
			stock.pop_back();
		}
		else{
			stock.push_back(a);
		}
	}
	
	for(unsigned int i=0; i<out.size(); ++i){
		std::cout << out[i] << std::endl;
	}
	
	return 0;
}