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<iostream>
using namespace std;
main(){int i=0,n,a[10];while(cin>>n){if(n)a[i++]=n;else cout<<a[--i]<<endl;}}

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

using namespace std;

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

	}

	return 0;
}

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

C++: #include <iostream>
using namespace std;
int main(){
    int car[10];
    int num;
    int i=0;
    while(1){
        cin>>num;
        if(num!=0){
            car[i]=num;
            i++;}
        else{
            i--;
            cout<<car[i]<<endl;
            car[i]=0;
        }
    }
    return 0;
}

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

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 <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string s;
  stack<int> st;
  while (getline(cin, s)) {
    int x = stoi(s);
    if (x) {
      st.push(x);
    } else {
      cout << st.top() << '\n';
      st.pop();
    }
  }
}

C++: #include<iostream>
#include<stack>
int main(){std::stack<int>s;for(int n;!(std::cin>>n).eof();)n?s.push(n):(std::cout<<s.top()<<'\n',s.pop());}

C++: #include<stdio.h>

int main(void)
{
	int d,T[100]={0},i=0,j=0,kai[100];

	while(scanf("%d",&d) != EOF)
	{
		if(d==0)
		{
			j-=1;
		    kai[i]=T[j];
     	    T[j]=0;
			i+=1;
		}
		else
		{
			T[j]=d;
	        j+=1;
		}
	}
    for(j=0;j<i;j++)
	{
		printf("%d\n",kai[j]);
	}
  return 0;
}

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<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int n;
    list<int> lst;
    lst.push_back(555);
    while(scanf("%d",&n)!=EOF){
        if(n==0){
            auto itr=lst.begin();
            printf("%d\n",*itr);
            lst.pop_front();
        }else{
            lst.push_front(n);
        }
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  vector<int>in;
  int a;
  while(cin>>a){
    if(a)in.pb(a);
    else {
      cout<<in[in.size()-1]<<endl;
      in.erase(in.end()-1);
    }
  }
}

C++: #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <stack>

using namespace std;

stack<int> s;
int n;

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

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

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

using namespace std;

stack<int> st;
queue<int> qu;
int a;

int main()
{
	while(cin >> a, !cin.eof())
	{
		
		if( a == 0 )
		{
			qu.push(st.top());
			st.pop();
		}
		else
			st.push(a);
	}
	
	while(!qu.empty())
	{
		cout << qu.front() << endl;
		qu.pop();
	}
	
	return 0;
}

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

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

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

int main(){
	int n,a=0,b=0;
	vector <int> g;
	while(true){
		cin>>n;
		if(n!=0){
			g.push_back(n);
		}else{
			n=g.back();
			g.pop_back();
			cout<<n<<endl;
		}
	}
	return 0;
}

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

C++: #include <stdio.h>

#define BUF_SIZE 256

class stack10 {
private:
	int stack[10];
	int index;
public:
	stack10() {
		for (int i=0; i<10; i++)  stack[i]=0;
		index=0;
	}
	void PutTrain(int n) {
		if (index<10)  stack[index++] = n;
		else  printf("error: put\n");
	}
	int PopTrain() {
		if (index>0)  return stack[--index];
		else {
			printf("error: pop\n");
			return -1;
		}
	}
};

int main(void) {
	stack10 s;
	int i, j;
	int num;
	char buf[BUF_SIZE];
	
	while (fgets(buf, sizeof(buf), stdin) != NULL) {
		sscanf(buf, "%d", &num);
		
		if (num == 0)  printf("%d\n", s.PopTrain());
		else s.PutTrain(num);
	}
	
	return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;
void pop(int *i,int a){
	cout<<a<<endl;
	*i++;
}
void push(int *i,int *a,int n){
	*i++;
	*a=n;
}
int main(){
	int a[100],i,n,j,k,p;

	for(i=0;i<100;i++){
		a[i]=0;
	}
	i=0;
	while(cin>>n){
		if(n==0){
			pop(&i,a[i]);
		}else{
			push(&i,&a[i+1],n);
		}
		i;
	}

    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main()
{
	vector<int> line;
	int pro;
	while(1)
	{
		cin>>pro;
		if(pro!=0){
			line.push_back(pro);
		}else{
			cout<<*(line.end()-1)<<endl;
			line.erase(line.end()-1);
		}
		if(line.empty())break;
	}
	return 0;
}

C++: #include <stdio.h>

int data[10];
int sp = 0;
int read;

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

void pop()
{
 sp--;
}

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

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