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

C++: import java.io.*;

 public class Main{
	 public static void main(String args[]) throws IOException{
		 BufferedReader bf = new BufferedReader(
				 new InputStreamReader(System.in));
		 int i = 0, j = 0,x;
		 int order[] = new int[10];
		 int exit[] = new int[1000];
		 String str;
		 while((str = bf.readLine()) != null){
			 x = Integer.parseInt(str);
			 if(x != 0){
				 order[i] = x;
				 i++;
			 } else {
				 exit[j] = order[i-1];
				 j++;
				 i--;
			 }
		 }
		 for(int c = 0; c < j; c++){
			 System.out.println(exit[c]);
		 }
	 }
}

C++: #include<stdio.h>
int main(){
  int sp=0,data[9],n,i;
  for(i=0;i<100;i++){
    scanf("%d",&n);
    if(n==0 && sp>0){
      sp--;
      printf("%d\n",data[sp]);
    }else{
      data[sp]=n;
      sp++;
    }
    if(sp==0)break;
  }
  return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	stack<int> car;
	int n;

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

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

using namespace std;

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

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

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

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

int main() {
int k=0,b;
int a[1000000];
while(cin>>b){
	if(b!=0){
		a[k]=b;
		k=k+1;
	}
	if(b==0){
		cout<<a[k-1]<<endl;
		k=k-1;
	
}
}
	return 0;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define sz(s) (long long)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
	for(T& e: vec) is >> e;
	return is;
}

template<typename T>
string join(vector<T>& vec, string sep=" "){
	stringstream ss;
	for(int i=0;i<(int)vec.size();i++){
		ss << vec[i] << (i+1==(int)vec.size()?"\n":sep);
	}
	return ss.str();
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll nCrmod(ll n,ll r){ll x=1,y=1; for(ll i=0;i<r;i++) {x=x*(n-i)%mod; y=y*(i+1)%mod; } return x*powmod(y,mod-2)%mod;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

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

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

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

	while(cin >> n){
		if(n!=0){
			st.push( n );
		}else{
			a = st.top();
			cout << a << endl;
			st.pop();
		}
	}
}