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 <cstdio>
#include <stack>
using namespace std;

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	stack<int> s;
	int n;
	while(1) {
		if(scanf("%d", &n) == EOF) break;
		if(n > 0) {
			s.push(n);
		} else if(n == 0) {
			if(!s.empty()) {
				cout << s.top() << endl;
				s.pop();
			}
		}
	}
}

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

int main(){

	std::stack<int> train;
	int buf;

	while(std::cin >> buf){

		if(buf == 0){

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

		}else{
			train.push(buf);
		}
	}
	return 0;
}

C++: #include <iostream>
#include <stack>
#include <queue>
#include <cstdio>
using namespace std;
int main(void)
{
  stack<int> in;
  queue<int> out;
  int c;
  while(scanf("%d",&c)!=EOF)
  {
    if(c==0){
      out.push(in.top());in.pop();
    }else{
      in.push(c);
    }
  }
  while(!out.empty())
  {
    cout<<out.front()<<endl;
    out.pop();
  }
  return 0;
}

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

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

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

int main(){
	vector<int> car, exit;
	int n;
	
	while( cin >> n ){
		
		if(n != 0){
			car.push_back(n);
		}else{
			exit.push_back( car.back() );
			car.pop_back();
		}
	}
	vector<int>::iterator it = exit.begin();

	while( it != exit.end() ){
		cout << *it << endl;
		++it;
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 1000000001
#define EPS 1.0e-6

using namespace std;

typedef long long ll;

int main()
{
	stack<int> s;

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

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n, train[100]={}, max=0;
    while(cin >> n){
        if(n != 0){
            for(int i=max; i>=0; i--){
                train[i+1]=train[i];
            }
            train[0]=n;
            max++;
        }
        else if(n == 0){
            cout << train[0] << endl;
            for(int i=1; i<=max; i++){
                train[i-1]=train[i];
            }
            max--;
        }
    }
    return 0;
}

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

int main(){
	stack<int> st;
	queue<int> q;
	int input;

	cin >> input;
	st.push(input);
	while(!st.empty()){
		cin >> input;
		if(input == 0){
			q.push(st.top());
			st.pop();
		}
		else{
			st.push(input);
		}
	}
	while(!q.empty()){
		cout << q.front() << endl;
		q.pop();
	}
}

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

C++: #include <iostream>
#include <stack>
using namespace std;
int main( void )
{
	int n;
	stack <int> S;

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

C++: /*AOJ 0013*/

#include<iostream>
#include<stack>

using namespace std;

int main(){

	stack<int> data;

	int tmp;

	cin>>tmp;

	data.push(tmp);

	int flag = 0;
	for(;;){

		flag = 0;

		cin>>tmp;

		if(tmp == 0){
			cout<<data.top()<<endl;
			data.pop();
			if(data.size()==0){
				flag = 1;
			}
		}
		else{
			data.push(tmp);
		}

		if(flag == 1){
			break;
		}
	}
	return 0;
}

C++: #include<stdio.h>

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

C++: #define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

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

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

using namespace std;

int main(){
	int operation;
	stack<int> s;

	while(cin >> operation){
		if(operation != 0){
                  s.push(operation);
		}  
		else if(operation == 0){
                  cout << s.top() << endl;
		  s.pop(); 
		}
	}
}

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

C++: #include<iostream>
#include<queue>
#include<stack>
#include<cstdio>
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<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>

using namespace std;

int main(){
	int n;
	vector<int> ans;
	stack<int> a;
	while (cin >> n) {
		if (n > 0)a.push(n);
		else if (n == 0) {
			int temp;
			temp = a.top();
			ans.push_back(temp);
			a.pop();
		}
	}
	for (int i = 0; i < ans.size(); i++)cout << ans[i] << endl;
	return 0;
}

C++: #include<iostream>

using namespace std;

#define DATA_MAX 20

void car_in( int car[] , int num );
void car_out( int car[] );


int main(void)
{
	int car[DATA_MAX];
	int num;

	while(1){

		cin >> num;
		if( cin.eof() ) break;

		if( num == 0 ){
			car_out( car );
		}
		else{
			car_in( car , num );
		}
	}

}

void car_in( int car[] , int num )
{
	for( int i = DATA_MAX - 1 ; i > 0 ; i-- )
	{
		car[i] = car[i-1];
	}
	car[0] = num;

	return;
}

void car_out( int car[] )
{
	cout << car[0] << endl;

	for( int i = 0 ; i < DATA_MAX-1 ; i++ )
	{
		car[i] = car[i+1];
	}

	return;
}

C++: #define scanf_s scanf
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 150
int main(void)
{
	int 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++: ///
// File:  0013.cpp
// Author: ymiyamoto
//
// Created on Mon Nov 20 21:20:22 2017
//

#include <cstdint>
#include <iostream>
#include <stack>

using namespace std;

int32_t main()
{
  stack<uint32_t> s;
  while (true) {
    uint32_t n;
    cin >> n;
    if (cin.eof()) break;

    if (n == 0) {
      cout << s.top() << endl;
      s.pop();
    } else {
      s.push(n);
    }
  }
  return 0;
}