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

using namespace std;

int main(int argc, char const *argv[]){
    int input; 
    stack<int> train_stack;
    vector<int> order;

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

    return 0;
}

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

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

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

using namespace std;

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

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

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

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int main(){
    stack<int> densha;
    for(int a; cin >> a; ){
        if(a == 0){
            cout << densha.top() << endl;
            densha.pop();
        }else
          densha.push(a);
    }
    return 0;
}

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

int main( void )
{
	stack <int> S;
	int first;
	cin >> first;
	S.push( first );

	string kotae = "";
	while ( S.empty() == false )
	{
		int n;
		cin >> n;
		if ( n == 0 )
		{
			ostringstream os;
			os << S.top() << endl;
			kotae += os.str();
			S.pop();
		}
		else
		{
			S.push( n );
		}
	}

	cout << kotae;

	return 0;
}

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

bool listen_input(int &);

void exec_order(std::stack<int> &,const int);

//--------------------main-------------------------
int main()
{
	using namespace std;
	
	stack<int> carStop;
	
	int order;
	while(listen_input(order))
	{
		exec_order(carStop,order);
	}
	
	return 0;
}
//-------------------------------------------------

bool listen_input(int &order)
{
	using namespace std;
	
	cin>>order;
	if(cin.eof())
	{
		return false;
	}
	else
	{
		return true;
	}
}

void exec_order(std::stack<int> &carStop,const int order)
{
	using namespace std;
	
	if(order)
	{
		carStop.push(order);
	}
	else
	{
		cout<<carStop.top()<<endl;
		carStop.pop();
	}
}

C++: #include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    int car[105];
    int num;
    int i=0;
    while(1){
        cin>>num;
        if(num!=0){
            car[i]=num;
            i++;}
        else{
            i--;
            cout<<car[i]<<endl;
            car[i]=0;
        }
    }
    return 0;
}

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

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

	//car's number
	int num = 0;

    //Until the end of input
	while(std::cin >> num){
        //if num = 0, output and delete
		if(num == 0){
			std::cout << st.pop() << std::endl;
        //if num != 0, input    
		} else {
			st.push(num);
		}
	}
}

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

C++: #include <cstdio>

int stack[10];
int cur = 0;

void push(int x){
	stack[cur] = x;
	cur++;
}

int pop(){
	cur--;
	return stack[cur];
}

int main(){
	int n;
	
	scanf("%d", &n);
	push(n);
	for(;;){
		scanf("%d", &n);
		if(n == 0){
			printf("%d\n", pop());
		}else {
			push(n);
		}
		if(cur == 0) break;
	}
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	stack<int> st;
	int x;
	while (cin >> x) {
		if (x == 0) {
			cout << st.top(); st.pop();
		}
		else st.push(x);
	}
}

C++: #include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<stack>
#include<set>
#include<cmath>

#define REP(i,s,e) for(int i=int(s);i<int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

#define EPS 1e-6

using namespace std;

int main(){

	stack<int>cars;

	int a;
	while(true){

	cin >> a;
	if(cin.fail()) break;

	if(a!=0) cars.push(a);
	else{
	     cout << cars.top() << endl;
	     cars.pop();
	}
	}

	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>
#include <stack>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
// BEGIN CUT HERE
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
// END CUT HERE

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

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

  return 0;
}

C++: #include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <algorithm>
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);
		}
	}
}

C++: #include<stdio.h>
int i=0,j=0;
int cars[19];

int main(){
    while(1)
    {
        scanf("%d",&cars[i]);
        if(cars[i]==0){
            printf("%d\n",cars[i-1]);
            i--;
            j++;
        }
        else
        {
            i++;
        }
        if(j==10)
        {
            break;
        }
    }
    return 0;
}

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

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

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

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

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

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

std::array<u_int, 100> stack;
int point=0;

void push(int p){
	stack[point]=p;
	++point;
}

void pop(){
	std::cout << stack[point] << std::endl;
	--point;
}

int main(){
	int num;

	for(int i=0;i<100;i++){
		std::cin >> num;
		if(num==0) pop();
		else push(num);
	}

    return 0;
}

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

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

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int now=-1;//0ツガツキツつスツづつォツづ可偲ヲツづィツ出ツつキツづ猟つォツ配ツ療ア
	int n[10]={0};
	int in;
	//for(;;){
		while(cin>>in){
		if(in==0){
			cout<<n[now];
			now--;
			if(now==-1)return 0;
		}
		else{
			n[now+1]=in;
			now++;
		}
	}
}