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>

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

C++: #include<iostream>
#include<stack>
using namespace std;
int main(){
  stack<int> chu;
  int i=0;
  int input;
  int hairetu[10];
  cin>>input;
  chu.push(input);
  while(cin>>input){
    if(input!=0){
      chu.push(input);
    }else{
      hairetu[i]=chu.top();
      chu.pop();
      i++;
    }
  }
  for(int j=0;j<=i-1;j++){
    cout<<hairetu[j]<<endl;
  }
  
}

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

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

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

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

using namespace std;

int main() {
	stack<int> line;
	int n;

	while (cin >> n) {
		if (n == 0) {
			cout << line.top() << endl;
			line.pop();
		}
		else {
			line.push(n);
		}
	}
	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<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;

int main(){
	queue<int> leave;
	stack<int> waiting;
	int n;
	while(scanf("%d",&n)==1){
		if(n==0){
			leave.push(waiting.top());
			waiting.pop();
		}else{
			waiting.push(n);
		}
	}
	while(!leave.empty()){
		cout<<leave.front()<<endl;
		leave.pop();
	}
	return 0;
}

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

int n;
stack<int> st;

int main() {
  while (1) {
    if (scanf("%d", &n) != 1) break;
    if (n == 0) {
      printf("%d\n", st.top());
      st.pop();
    } else {
      st.push(n);
    }
  }
}

C++: /*AOJ 0013*/

#include<iostream>
#include<stack>
#include<queue>

using namespace std;

int main(){

	stack<int> data;
	queue<int> ans;

	int tmp;

	cin>>tmp;

	data.push(tmp);

	int flag = 0;
	while(cin>>tmp){

		flag = 0;

		if(tmp == 0){
			ans.push(data.top());
			data.pop();
		}
		else{
			data.push(tmp);
		}

	}
	while(ans.size()!=0){
		cout<<ans.front()<<endl;
		ans.pop();
	}

	return 0;
}

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

using namespace std;

int main(){

  vector<int> V;

  while(1){
    int in;
    cin >> in;
    if(in != 0) V.push_back(in);
    else{
      cout <<  V.back() << endl;
      V.pop_back();
    }
    
    if(V.empty())break;
  }
  return 0;
}

C++: #include <stdio.h>

#define N 20
int main(void){
    int stk[N], sp=0;
    int n;
   
    while (scanf("%d", &n)){
        if (n==0 && sp!=0){
            printf("%d\n", stk[--sp]);
        } else {
            stk[sp++] = n;
        }
    }
    return 0;
}

C++: #include<cstdio>
#include<stack>
using namespace std;
int main(){
  stack<int> s;
  do{
    int num;scanf("%d",&num);
    if(num){
      s.push(num);
    }else{
      printf("%d",s.top());
      s.pop();
    }
  }while(!s.empty());
}

C++: #include <stdio.h>
#include <stack>
using namespace std;

int main(){
    
    int input;
    stack<int> train;
    while (scanf("%d",&input)!=EOF) {
        if (input!=0)train.push(input);
        else {
            printf("%d\n",train.top());
            train.pop();
        }
    }
}

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

using namespace std;
int main(){
  int op;
  stack<int> intStack;
  while(cin>> op){
    if(op == 0){
      cout << intStack.top() << endl;
      intStack.pop();
    } else {
      intStack.push(op);
    }
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	int stack[10];
	int n=0;
	int d;
	while(cin>>d){
		if(d!=0){
			stack[n++]=d;
		}else{
			cout<<stack[--n]<<endl;
		}
	}
}

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

using namespace std;

int main()
{
    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>
using namespace std;
int main(){
long n,nn[10],i=0;
while(cin>>n){
if(n)nn[i++]=n;else cout<<nn[--i]<<endl;
}
return 0;
}

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

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

C++: #include<stdio.h>
const int SIZE=100;
int data[SIZE];
int sp=0;
int size(){
  return sp;
}
int empty(){
  return sp<=0;
}
int top(){
  return data[sp-1];
}
void pop(){
  sp--;
}
void push(int v){
  data[sp]=v;
  sp++;
}
int main(){
  int n;
  while(n!=EOF){
    scanf("%d",&n);
    if(n==0){
      printf("%d\n",top());
      pop();
    }else{
      push(n);
    }
  }
  return 0;
}

C++: #include<stdio.h>
#include<stack>
using namespace std;

int main(){
  int n;
  stack<int> r;
  while(scanf("%d",&n)!=EOF)
    if(n){
      r.push(n);
    }else{
      printf("%d\n",r.top());
      r.pop();
    }
  return 0;
}

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

int main(){
	int n,count = 0;
	stack<int> get;
	while(1){
		cin >> n;
		if(n==0){
			cout <<  get.top() << endl;
			get.pop();
			count -= 1;
		}
		else{
			get.push(n);
			count += 1;
		}
	}
	return 0;
}

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

int main(){
	std::vector<int> carsQueue;
	int switchingRailroadCarsNumber;
	while (std::cin >> switchingRailroadCarsNumber){
		if (switchingRailroadCarsNumber != 0){
			carsQueue.push_back(switchingRailroadCarsNumber);
		}
		else{
			std::cout << carsQueue.at(carsQueue.size() - 1) << std::endl;
			carsQueue.pop_back();
		}
	}
	return 0;
}

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

int main() {
	ios :: sync_with_stdio(false);
	stack <int> s;
	int n;
	while(cin >> n) {
		if(n == 0) {
			cout << s.top() << '\n';
			s.pop();
		} else
			s.push(n);
	}
	return 0;
}

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

int main(){
	std::deque<int> que;
	int tmp;
	while(std::cin >> tmp){
		if(tmp == 0){
			std::cout << que.back() << std::endl;
			que.pop_back();
		}
		else que.push_back(tmp);
	}
		return 0;
	}