Go: package main

import "fmt"

func main() {
	stack := []int{}
	for {
		var a int
		i, _ := fmt.Scan(&a)
		if i == 0 {
			break
		}
		if a == 0 {
			fmt.Println(stack[len(stack)-1])
			stack = stack[:len(stack)-1]
			continue
		}
		stack = append(stack, a)
	}
}

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

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

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

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

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    stack<int> stk;
    for(;;){
        int n;
        if(!(cin >> n))
            return 0;

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

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

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

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

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

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

int main(int argc,char* argv[]){
  std::vector<int> vec(1000);
  
  while(!std::cin.eof()){
    int temp;
    std::cin >> temp;
    if(temp == 0){
      std::cout << vec.back() << std::endl;
      vec.pop_back();
      continue;
    }else{
      vec.push_back(temp);
      continue;
    }
  }

  return 0;
  
}

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

using namespace std;

int number[100];
int car;
int position = 0;

int main(){
	while(cin >> car){
		if(car > 0){
			number[position] = car;
			position++;
		}else{
			position--;
			cout << number[position] << endl;
		}
	}
}

C++: 
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	vector<int> train;
	int a;
	do {
		cin >> a;
		if (a == 0) {
			cout << train.back() << endl;
			train.pop_back();
		}
		else {
			train.emplace_back(a);
		}
	} while (train.size()!=0); 
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)


using namespace std;


int main(void)
{
    int a[110][2] ={0};
    int i = 0,j = 0,k = 0,l = 0;
    int answer[101] = {0};
    bool judge = true;
    int tempjudge = 0;
    
    while(judge)
    {
        cin >> a[i][0];
        if(a[i][0] == 0)
        {
            a[i][1] = 1;
            RFOR(j,i,-1)
                if(a[j][1] != 1 )
                {
                    answer[l] = a[j][0];
                    a[j][1] = 1;
                    l++;
                    break;
                }
        }
        REP(k,i+1)
        if(a[k][1] != 1){
                judge = true;
                break;
        }
        else
            judge = false;
                
        
        i++;
    }
    REP(m,l)
    cout << answer[m] << endl;

    return 0;
}

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

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

C++: #include <iostream>

using namespace std;
int main(){
  int a[100],k = 0,o;
  while(1){
    cin >> o;
    if(o == 0){
      cout << a[k-1] << endl;
      k--;
    } else {
      a[k++] = o;
   }
    if(k == 0)break;
  }
}

C++: #include <cstdio>
#include <stack>
using namespace std;
int main(){
	int n;
	stack<int> car;
	while(scanf("%d",&n)) {
		if(n!=0) car.push(n);
		else{
			printf("%d\n",car.top());
			car.pop();
		}
	}	
	return 0;
}

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

using namespace std;

int main()
{
    stack<int> st;

    int a;

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

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)


using namespace std;


int main(void)
{
    int a[201][2] ={0};
    int i = 0,j = 0,k = 0,l = 0;
    int answer[201] = {0};
    bool judge = true;
    int tempjudge = 0;
    
    while(judge)
    {
        cin >> a[i][0];
        if(a[i][0] == 0)
        {
            a[i][1] = 1;
            RFOR(j,i,-1)
                if(a[j][1] != 1 )
                {
                    answer[l] = a[j][0];
                    a[j][1] = 1;
                    cout << "ouput"<< answer[l] << endl;
                    l++;
                    break;
                }
        }
        REP(k,i+1)
        if(a[k][1] != 1){
                judge = true;
                break;
        }
        else
            judge = false;
                
        
        i++;
    }

    return 0;
}

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

using namespace std;

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

C++: #include <stdio.h>
#include <vector>
using namespace std;

int main(){
	vector<int> hoge;
	int n;
	
	while( scanf("%d", &n) != EOF ){
		
		if(n==0){
			printf("%d\n" , hoge.back());
			hoge.pop_back();
		}else{
			hoge.push_back(n);
		}
		if(hoge.size()==0) break;
	}
	
	return 0;
}

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

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

C++: #include<iostream>
#include<stack>
using namespace std;
 
int main(){
    int i,cnum = 0;
    stack<int> car;
    while(cin >> i){
        if(i != 0){
            car.push(i);
            cnum++;
        }else if(cnum == 0){
            
        }else{
            cout << car.top() << endl;;
            car.pop();
            cnum--;
        }
    }
    return 0;
}

C++: #include <stdio.h>

int main() {
	int a,i,k,m;
	int data[15] = {0};
	int output[15] = {0};
	for (i = 0; i < 15; i++) {
		scanf("%d", &a);
		if (a != 0) {
			for (k = 0; k < 15; k++) {
				if (data[k] == 0) {
					data[k] = a;
					break;
				}
			}
		}
		else {
			for (k = 0; k < 15; k++) {
				if (data[k] == 0) {
					for (m = 0; m < 15; m++) {
						if (output[m] == 0) {
							output[m] = data[k - 1];
							break;
						}
					}
					data[k - 1] = 0;
					break;
				}
			}
		}
	}
	printf("\n");
	for (i = 0; i < 15; i++) {
		if (output[i] != 0) {
			printf("%d\n", output[i]);
		}
	}
	return 0;
}