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<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;
}

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

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

#define MAX 256

int main(void){
	
	int i=0,x;
	int a[MAX];
	int ans[MAX];
	while(cin>>x){
		if(x==0){
			cout<<a[i-1]<<endl;
			i--;
		}else{
			ans[i]=x;
			i++;
		}
		
		
	}
	
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;

inline bool IN(int x, int y, int w, int h)
{
    return 0 <= x && x < w && 0 <= y && y < h;
}


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


}

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

int main(){
int answer[10];
int a,b;
b=0;
stack<int> train;
while(cin>>a){
if(a==0){
cout<<train.top()<<endl;
train.pop();}
if(a!=0){
	train.push(a);}}}

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

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

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

	
}

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

int main(){
    int n;
    std::stack<int> stack;
    while(1){
        std::cin >> n;
        if(n == 0){
            std::cout << stack.top() << std::endl;
            stack.pop();
        }
        else
        {
            stack.push(n);
        }
        if(std::cin.eof())
            break;
    }
}

C++: #include <iostream>
#include <vector>
#include <math.h>
#include <string>
#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 <vector>
#include <stack>
using namespace std;

int main(){
  int e;
  stack<int> S;
  while(cin >> e){
    if(e > 0){
      S.push(e);
      continue;
    }
    cout << S.top() << endl;
    S.pop(); 
  }

  return 0;
}