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>
using namespace std;


int main(){

  int train , num[20] , k = 0 , count[20];

 for( int i = 0; i < 20; i++ ){
   count[i] = 0;
    num[i] = 0;
 }

 while( cin >> train ){
   
   ++k;
   num[k] = train;
    if( train == 0 ){
      for( int j = 20; j >= 0; j-- ){
	if( num[j] != 0 ){
	count[k] = num[j];
	num[j] = 0;
	break;
	}
      }
    }
  }
 
  
  for( int k = 0; k < 20; k++ ){
    if( count[k] != 0 ) cout  << count[k] << endl; 

  }


  return 0;
}

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

int main(void){
     int n[100];
     int i=0;
     int d;
     do{
	  cin >> d;
	  if(d == 0){
	       cout << n[i-1] << endl;
	       i = i-1;
	  }else{
	       n[i] = d;
	       i = i+1;
	  }
//	  cout << endl;
//	  for(int i=0;i<10;i++){
//	       cout << n[i-1] << endl;
//	  }
//	  cout << endl;
     }while(i!=0);

     return 0;
}

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

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

C++: #include <iostream>
#include <stack>
    
int main(){
    std::stack<u_int> train;
    u_int num;
    while(std::cin >> num){
        if(num == 0){
            std::cout << train.top() << std::endl;
            train.pop();
        }else{
            train.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%10>0){p[i]=x;i++;}
else{i--;printf("%d\n",p[i]);}

}
return 0;
}

C++: //Switching Railroad Cars

//vñF0ªüÍ³ê½çStack©çpopµÄ»êðoÍµëA»êÈOÍpushµÆ¯
//üÍª³µ¢±ÆÍÛá³êÄ¢é@¿ÈÝÉpush³êéàÌÍ1`10çµ¢

//ÅÍX^bNÍóÅ é@ÉX^bNªóÉÈéÜÅ±¯æ

#include<iostream>
#include<stack>
using namespace std;

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

C++: #include<iostream>
using namespace std;
int main(){
  int number,count1,count2,enter[10],leave[10],sum;
  sum=0;
  count1=0;
  count2=0;
  while(1){
    cin >> number;
    if(number!=0){sum++;
      enter[count1]=number;
      count1++;}
    else if(number==0){
      count1--;
      leave[count2]=enter[count1];
      count2++;}
    if(sum-1<count2)break;
			}
  for(int i=0;i<count2;i++){
    cout << leave[i]<< endl;
  }
 
  return 0;
  }

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++: {
stack<int>a;
int b;
scanf("%d",&b);
a.push(b);
while(cin>>b){
	if(b)a.push(b);
	else {printf("%d\n",a.top());a.pop();}
}
}

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

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,k;
  while(1){
    scanf("%d",&n);
    if(n==EOF)break;
    if(n==0){
      printf("%d\n",top());
      pop();
    }else{
      push(n);
    }
  }
  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(!chu.empty()){
    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++: q=[];require("fs").readFileSync("/dev/stdin","utf8").trim().split('\n').map(function(i){i?q.push(i):console.log(q.pop())})

C++: #include <iostream>

using namespace std;

int main(){
  short stack[10]={0};
  short *pstack=stack;
  while(1){
    int num;
    cin>>num;
    if(num){
      *pstack=num;
      pstack++;
    }else{
      pstack--;
      cout<<*pstack<<endl;
    }
  }
}

C++: #include<stack>
#include<deque>
#include<iostream>
using namespace std;
int main(){
	int m,n;
	deque<int>deq;
 	while(1){
	    cin>>n;
	    if(cin.eof()) break;
	    if(n!=0) deq.push_back(n);
	    else {  
                     if(deq.empty()) { continue;}
                     else {     cout<<deq[(int)deq.size()-1]<<endl;
				deq.pop_back();}
            }
	}
        return 0;
}

C++: #include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int main(){
    stack <int> st;
    int n;
    while(cin >> n){
        if(n)
            st.push(n);
        else{
            cout << st.top() << endl;
            st.pop();
        }
    }
}

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

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

C++: #include<iostream>
#include<stack>
#include<vector>
int main(){
	std::stack<int> st;
	std::vector<int> vec;
	int a=0;
	while(1){
		int n;
		std::cin>>n;
		if(std::cin.eof())break;
		if(n!=0)st.push(n);
		else vec.push_back(st.top()),a++,st.pop();
	}
	for(int i=0;i<a;i++)std::cout<<vec[i]<<std::endl;
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <queue>
#include <cmath>
#include <stack>

#define int64 long long int

using namespace std;

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

	while(cin >> n){
		if(n==0){
			cout << st.top() << '\n';
			st.pop();
		} else {
			st.push(n);
		}
	}	
	
	return 0;
}

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

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

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

int main(){
  std::stack<int>s;
  for(int x;~scanf("%d",&x);)
    if(x)s.push(x);
    else printf("%d\n",s.top()),s.pop();
}

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

int main(){
	int x;
	stack<int> S;
	while(1){
		cin>>x;
		if(x==0){
			printf("%d\n",S.top());
			S.pop();
		}else{
			S.push(x);
		}
	}
	return 0;
}

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

using namespace std;

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

  return 0;
}

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

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