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 <bits/stdc++.h>

//const static double	de_PI	= 3.14159265358979323846;
//const static int	de_MOD	= 1000000007;
//const static int	de_MAX	= 999999999;
//const static int	de_MIN = -999999999;

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int n = 0;
	std::stack<int> S;
	std::vector<int> ans;

	while (std::cin >> n) {
		if (n != 0) {
			S.push(n);
		}
		else {
			ans.push_back(S.top());
			S.pop();
		}
	}

	for (int i = 0; i < ans.size(); i++) {
		std::cout << ans[i] << std::endl;
	}

}

C++: #include<stdio.h>

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

C++: 

#include <cstdio>
#include <bitset>
#include <cmath>
#include <complex>
#include <vector>
#include <algorithm>
#include <stack>

#define EPS 1e-6

using namespace std;
typedef complex<double> coor;

double cross(coor a, coor b)
{
  return a.real() * b.imag() - a.imag() * b.real();
}

double dot(coor a, coor b)
{
  return a.real() * b.real() + a.imag() * b.imag();
}

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

C++: #include<iostream>
#include<stack>
#include<cstdio>
#include<vector>
using namespace std;
int a;


int main(int argc, char *argv[])
{
  stack<int> s;
  vector<int> m;
  while(cin>>a){
    if(a == 0){
      m.push_back(s.top());
      s.pop();
    }else{
    s.push(a);
	}
  }
  int S = m.size();
  for(int i= 0;i < S;i++){
    cout<<m[i]<< endl;
  }
  return 0;
}

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);
	while(scanf("%d", &n) != EOF){
		if(n == 0){
			printf("%d\n", pop());
		}else {
			push(n);
		}
	}
	return 0;
}

C++: #include<iostream>
#include<stack>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)

using namespace std;


int main(){
	stack<int> rail;
	int num;

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


}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <stack>
using namespace std;
int main(){
  int n;
  stack<int> in,out;
  while(cin>>n){
    if(!n)out.push(in.top()),in.pop();
    else{in.push(n);}
    if(in.empty()&&!out.empty())break;
  }
  while(!out.empty()){
    cout<<out.top()<<endl;
    out.pop();
  }
  return 0;
}

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


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

	while (true) {
		cin >> n;
		if (n == 0) cout << a.top() << endl, a.pop();
		else a.push(n);
		if (a.empty()) break;
	}


	return 0;
}

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

using namespace std;

int main()
{
    int num;
    stack<int> rail;

    while (cin >> num) {
        if (num > 0) {
            rail.push(num);
        }
        else {
            cout << rail.top() << "\n";
            rail.pop();
        }
    }

    return 0;
}

C++: n,*a=&n;main(){for(;~scanf("%s",a);)*a%8?a++:puts(--a);}

C++: #include<stack>
#include<iostream>
using namespace std;
int main(){
	int n;
	stack<int>st;
 	while(1){
	    cin>>n;
	    if(n!=0) st.push(n);
	    else    {cout<< st.top()<<endl;
		     st.pop();}
	}
        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;
}

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

signed main() {
	vector<int>a;
	int b;
	while (cin >> b) {
		if (b)a.push_back(b);
		else { cout << a[a.size() - 1] << endl; a.pop_back(); }
	}
}

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

int main() {
	vector<int>v;
	vector<int>::iterator pv=v.begin();
	int n;
	while (cin>>n) {
		if (n == 0) {
			int x = v.size();
			cout << v[x - 1] << endl;
			v.pop_back();
		}
		v.push_back(n);	
	}
	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 <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int input;
    stack<int> sta;

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

    return 0;
}

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

int main()
{
    std::stack<int> s;
    while (true) {
        int n;
        std::cin >> n;
        if (std::cin.eof()) break;

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

C++: #include<stdio.h>
int main(){
int a[100];
int j;
for(int i=0;;i++){
scanf("%d",&a[i]);
if(a[i]==0){
j=i;
while(){
if(j1!=0){
printf("%d",a[j1]);
break;
}
j--;
}
a[j-1]=0;
}
}

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

using namespace std;

int n;
int a[10000];
int i = 0;

int main(void)
{
	stack<int> s;
	while(scanf("%d", &n) != EOF){
		if(n == 0){
			a[i] = s.top();
			s.pop();
			i++;
		}
		else{
			s.push(n);
		}
	}
	
	for(int j = 0; j < i; j++){
		printf("%d\n", a[j]);
	}
	
	return 0;
}

C++: #include<stdio.h>


struct STACK
{
	int num[ 10 ] ;
	int p ;
	
	int		Top( void )	;
	void	Push( int )	;
	void	Pop( void )	;
	void	Init( void ) ;
} stack ;


int main( void )
{
	stack.Init() ;

	int kale ;
	while( scanf( "%d" ,&kale ) != EOF )
	{
		if( kale == 0 )
		{
			printf( "%d\n" ,stack.Top() ) ;

			stack.Pop() ;
		}

		else
		{
			stack.Push( kale ) ;
		}
	}

	return 0 ;
}


void STACK::Init( void )
{
	p = 0 ;
}

void STACK::Push( int kale )
{
	num[ p++ ] = kale ;
}

void STACK::Pop( void )
{
	--p ;
}

int STACK::Top( void )
{
	return num[ p - 1 ] ;
}

C++: #include<iostream>
using namespace std;
int main(){
  
  int a[10],b[10],c=0,d=0,num;

  while(1){

    cin >>num;

    if(num != 0){
      a[c]=num;
      c++;
    }else{
      b[d]=a[c-1];
      c--;
      d++;
    }

    if( c == 0 )break;

  }

  for(int i=0 ; i < d ; i++){
    cout <<b[i]<<endl;
  }

  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main (int argc, char * const argv[]) {
    // insert code here...
    int n;
	vector<int> densha;
	
	while(cin>>n){
		if(n==0){
			cout << densha[densha.size()-1]<<endl;
			densha.pop_back();
		}else{
			densha.push_back(n);
		}
	}
	
	return 0;
}