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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>
#include <stack>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
// BEGIN CUT HERE
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
// END CUT HERE

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

  while(scanf("%d", &in) != EOF){
    if(in == 0){
      printf("%d\n",s.top());
      s.pop();
    }
    else s.push(in);
  }

  return 0;
}

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

int main() {
	int a;
	vector<int> A;
	while (cin >> a) {
		if (a == 0) {
			cout << A.back() << endl;
			A.pop_back();
		}
		else A.push_back(a);
	}
	return 0;
}

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

using namespace std;

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

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

int main() {
	
	int c[256],e[256],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>
#include<stack>

using namespace std;

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

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

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

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

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

int main(){
	int n;
	stack<int> stk;
	queue<int> que;
	while(cin>>n){
		if(n==0){
			que.push(stk.top());
			stk.pop();
		}else{
			stk.push(n);
		}
	}
	while(!que.empty()){
		cout<<que.front()<<endl;
		que.pop();
	}
	return 0;
}

C++: //#define scanf_s scanf
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 100
int main(void)
{
	int n, now = 0;
	int list[MAX] = { 0 };
	do{
		scanf_s("%d", &n);
		if (n != 0) { list[now] = n; ++now; }
		else { --now; printf("%d\n", list[now]); }
	} while (now != 0);
}

C++: #include <stdio.h>
#include <stack>

using namespace std;

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

C++: #include<iostream>

using namespace std;

int main() {
	int train[11] = { 0 }, junban[11] = { 0 }, a = 0, n, i;	
	while (cin >> n) {
		if (n == 0) {
			for (i = 0; train[i] != 0; i++) {;}
			junban[a] = train[i - 1];
			train[i - 1] = 0;
			a++;
		}
		else {
			for (i = 0; train[i] != 0; i++) {;}
			train[i] = n;
		}
	}
	for (i = 0; junban[i] > 0; i++) {
		cout << junban[i] << endl;
	}
	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,k;
  while(1){
    scanf("%d",&n);
    if(n==0){
      printf("%d\n",top());
      pop();
    }else{
      push(n);
    }
    if(n==empty)break;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n; i++){
const int INF = 1 << 25;
 
stack<int> cars;
int numbar;
 
int main(){
    while(scanf("%d", &numbar) != EOF){
        if(numbar == 0){
            printf("%d\n", cars.top());
            cars.pop();
            continue;
        }
        cars.push(numbar);
    }
    return 0;
}

C++: #include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
	int n, p = 1, *a = (int *)calloc(11, sizeof(int));
	
	while(cin >> n){
		if(n == 0){
			p--;
			cout << a[p] << endl;
		} else {
			a[p] = n;
			p++;
		}
	}
	
	free(a);
	return 0;
}

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

C++: #include <stdio.h>
const int SIZE = 100;
int data[SIZE];
int sp= 0;

int size(){
 return sp;
}

int top(){ return data[sp-1];
}
void pop(){
 sp--;
}

void push(int v){
 data[sp] = v;
 sp++;
}

int main(){
 int v;
 while(scanf("%d", &v)) != EOF){
  if(v != 0){
    push(v);
  }
  if(v == 0){
   pop();
  }
  top();
 }
}

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

C++: #include <iostream>
using namespace std;
int main(void){
    int in,i = 0,syako[1000];
    while(cin >> in){
        if(in != 0){
            syako[i] = in;
            i++;
        }
        else{
            cout << syako[i - 1] << endl;
            i--;
        }
    }
}

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

stack<int> sta;

int main(void)
{
  int a;
  while(1){
    cin>>a;
    if(a)
      sta.push(a);
    else{
      cout<<sta.top()<<endl;
      sta.pop();
    }
  }
  return 0;

}

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

using namespace std;

int main(){
	vector<int> a;
	for(int n; cin >> n;){
		if(!n) cout << a[a.size() - 1] << endl, a.pop_back();
		else a.push_back(n);
	}
	return 0;
}

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

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

int main(){
	int out[10], car[10] = {0};
	int x, k = 0, i = 0;
	while(cin >> x){
		if(x != 0){
			car[i] = x;
		}
		else{
			out[k] = car[i-1];
			i = i-2;
			k++;
		}
		i++;
	}
	for(int j = 0; j < k; j++){
		cout << out[j] << endl;
	}
}

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

int main() {
	int n;
	vector<int> train;
	
	while (cin >> n) {
		if (n != 0) {
			train.push_back(n);
		}
		else {
			cout << train.back() << endl;
			train.pop_back();
		}
	}

	return 0;
}

C++: #include<stdio.h>

int main()
{
	int x[100]={0},y[100]={0},z,n,t=0,r=0;
	while(scanf("%d",&n) !=EOF)
	{
		if(n>=1)
		{
			x[t]=n;
			t++;
		}
		else if(n==0)
		{
			t--;
			y[r]=x[t];
			r++;
		}
	}
	
	for(z=0;z<r;z++)
	{
		printf("%d\n",y[z]);
	}
	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.pop() << std::endl;
		else que.push(tmp);
	}
		return 0;
	}