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

int main(void){
     int n[10];
     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>

using namespace std;

int main() {

    int i = 0,j,k = 0,n,grage[100],box[100];
    
    while(cin >> n){
        box[i] = n;
        i++;
    }
    
    for(j = 0;j < i;j++){
        if(box[j] != 0){
            grage[k] = box[j];
            k++;
        }
        else {
            cout << grage[k - 1] << endl;
            k--;
        }
    }
    
    return 0;
}

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

int main(){
	std::vector<int> rail;
	std::vector<int> out;
	int a;

	while(std::cin >> a){
		if(a != 0){
			rail.push_back(a);
		}else if(a == 0){
			out.push_back(rail.back());
			rail.pop_back();
		}
	}

	for(int i=0; i<(int)out.size(); ++i){
		std::cout << out.at(i) << std::endl;
	}
}

C++: #include<bits/stdc++.h>

using namespace std;

int str1[11],str2[11],mo;

int  s=1,t1,t2;

int main(){


    while(1){

    cin >> mo;


    if(mo!=0){
        str1[t1]=mo;
        t1++;

    }else {
        str2[t2++]=str1[--t1];

    }

    if(t1==0)break;

    }

    for(int i=0;i<11;i++){

            if(str2[i]==0)break;
        cout << str2[i] << endl;
    }


return 0;
}

C++: /*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main()
{
int x=0,y=0,z=0,w=0,n=0;
string b;
stack<int> s;
while(std::cin >> x){
  if(x==0){
    std::cout << s.top() << '\n';
    s.pop();
  }else{
    s.push(x);
  }
}

}

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

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

C++: #include <iostream>
#include <stack>
using namespace std;int main(){int n;stack<int> t;while(cin>>n){if(n)t.push(n);else{cout<<t.top()<<endl;t.pop();}}}

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

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

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
    int a;
    vector<int> s;
    vector<int> t;
    while(cin>>a){
        if(a!=0){
            s.push_back(a);
        }else{
            s.pop_back();
            t.push_back(s[s.size()-1]);
            s.pop_back();
        }
    }
    for(int i=0;i<t.size();i++){
        cout << t[i] << endl;
    }
    return 0;
}

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

int main(){
	stack<int> garage;

	int car = 0;
	while(cin >> car){

		if(car != 0){
			garage.push(car);
		}else{
			cout << garage.top() << endl;
			garage.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 isfull(){
  return sp>=SIZE;
}
int top(){
  return data[sp-1];
}
void pop(){
  sp--;
}
void push(int v){
  data[sp]=v;
  sp++;
}
int main(){
  int k,n;
  for(k=0;k<100;k++){
    scanf("%d",&n);
    if(!empty()){
      if(n==0){
        printf("%d\n",top());
        pop();
      }
    }else{
      if(!isfull()){
        push(n);
      }
    }
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(void) {
	int input_num;
	vector<int> train_num;
	while (cin >> input_num) {
		if (input_num == 0) {
			cout << train_num.back() << endl;
			train_num.pop_back();
		}
		else{
			train_num.push_back(input_num);
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

	int i, j=0, n, a[10], b[10];

	for(i=0; i<10; i++) {
		b[i]=0;
	}

	for(i=0; i<10; i++) {
		cin >> n;
		if(n==0) {
			b[j]=a[i-1];
			j++;
			i--;
			a[i]=n;
			if(i==0)
				break;
			i--;
			continue;
		}
		a[i]=n;
	}

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

	char s;
	cin >> s;

	return 0;

}

C++: #include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main() {
	
	int c[10],e[10],m,n=0,k=0;
	for(int i=0;i<10;i++){c[i]=0;e[i]=0;}
	
	while(cin>>m){
		if(m==0){e[k]=c[n-1];k++;c[n-1]=0;n--;}
		else {c[n]=m;n++;}
	}
	
	for(int i=0;i<k;i++)cout<<e[i]<<endl;
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int a[]={0,0,0,0,0,0,0,0,0,0};
int b;
while(cin>>b){
if(b==0){
cout<<a[0]<<endl;
for(int i=0;i<9;i++){
a[i]=a[i+1];}}
else{
for(int i=0;i<9;i++){
a[9-i]=a[8-i];}
a[0]=b;}}}

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;
if(j-1==0){
break;
}
}
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  stack<int> n;
  int a;
  while(cin >> a){
    if(a != 0)n.push(a);
    else{
      cout << n.top()<<endl;
      n.pop();
    }
  }
  return 0;
}