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>
#include <stack>

int main(){
	std::stack<int> garage;
	int vehicle_num; //railroad car
	
	while(std::cin >> vehicle_num){
		if(vehicle_num != 0) garage.push(vehicle_num);
		else{
			std::cout << garage.top() << std::endl;
			garage.pop();
		}
	}
	
	return 0;
}

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

int main() {
	int in;
	vector <int> a;
	while (1) {
		cin >> in;
		if (in == 0) {
			cout << a[a.size() - 1];
			a.erase(a.end() - 1);
			if (a.size() == 0)
				break;
			else
				cout << endl;
		}
		else
			a.push_back(in);
	}
	return 0;
}

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

int main(){
	int n,i,count = 0,x = 0,put[10];
	stack<int> get;
	while(1){
		cin >> n;
		if(n==0){
			put[x] = get.top();
			get.pop();
			count -= 1;
			x += 1;
		}
		else{
			get.push(n);
			count += 1;
		}
		if(count == 0) break;
	}
	for(i=0;i<x;i++){
		cout << put[i] << endl;
	}
	return 0;
}

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

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

int main(void)
{
    std::stack<int> n;
    int m;

    while(std::cin >> m)
    {
        if(m == 0)
        {
            std::cout << n.top() << std::endl;
            n.pop();
        }

        else
        {
            n.push(m);
        }
    }

    return 0;
}

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

using namespace std;

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

C++: // includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n;
  vector<int> vec;
  while(cin >> n){
    if(n != 0)vec.pb(n);
    else{
      cout << vec[vec.size() - 1] << endl;
      vec.pop_back();
    }
  }
	return 0;
}

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

stack<int> st;

int main() {
	
	int m, tmp;
	
		
		for(;;)  {
			cin >> m;
			if(m > 0)  {
				st.push(m);
			}
			else if(m == 0)  {
				cout << st.top() << endl;
				st.pop();
				if( st.empty())
				return 0; 
			}
		}	
	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;
				}
			}
		}
		if (data[0] == 0) {
			break;
		}
	}
	for (i = 0; i < 15; i++) {
		if (output[i] != 0) {
			printf("%d\n", output[i]);
		}
	}
	return 0;
}

C++: #include <stdio.h>

int main(){
	int i=0, j=0, num;
	int a[20], b[20];
	for(int i=0 ; i<20 ; i++){
		a[i] = 0;b[i]=0;
	}
	
	while( scanf("%d", &num) != EOF ){
		if(num==0){
			b[j] = a[i-1];
			j++;
			i--;
		}else{
			a[i] = num;
			i++;
		}
	}
	for(int n=0; n<j ; n++){
		printf("%d\n", b[n]);
	}
	
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <iomanip>

using namespace std;


int main(void)
{
	int a[100], g = 0,co = 0;

	while (cin >> g)
	{
		if (g != 0)
		{
			co++;
			a[co] = g;
		}
		else
		{
			cout << a[co] << endl;
			a[co] = 0;
			co--;
		}
	}
	return 0;
}

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

using namespace std;

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

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

int main(){
	int a;
	std::stack<int> stack;

	while(std::cin >> a){
		if(a > 0){
			stack.push(a);		//push
		} else{
			std::cout << stack.top() << std::endl;	//表示
			stack.pop();		//pop
		}
	}

	return 0;
}

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

int main(){
	int i=0;
	std::stack<int> train;
	scanf("%d",&i);
	train.push(i);
	while(1){
		scanf("%d",&i);
		if(i==0){
			printf("%d\n",train.top());
			train.pop();
		}else{
			printf("%d\n",train.top());
			train.pop();
			train.push(i);
		}
	}
	return 0;
}

C++: #include <stdio.h>  

int main(){
    int hi[10];
    int n,count=0;
    while(scanf("%d",&n) != EOF){
	if(n == 0){
	    printf("%d\n",hi[count-1]);
	    hi[count-1]=0;
	    count--;
	}
	else{
	    hi[count]=n;
	    count++;
	}
    }
    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);
	}
	while(!s.empty()){
		cin >> num;
		if(num!=0){
			s.push(num);
		}
		else{
			cout << s.top() << "\n";
			s.pop();
		}
	}
	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();
		}
	}
}

C++: #include<iostream>
using namespace std;
int main(){
  
  int a[10],c=0,num;

  while(1){

    cin >>num;

    if(num >= 1 && num <=10){
      a[c]=num;
      c++;
    }else{
      cout <<a[c-1]<<endl;
      c--;
    }   

  }
  return 0;

}

C++: #include <iostream>
#include <vector>
#include <stack>
using namespace std;
int main() {
  stack<int> s;
  vector<int> v;
  int n;
  while (cin >> n) {
    if (n == 0 && !s.empty()) {
      v.push_back(s.top());
      s.pop();
    } else {
      s.push(n);
    }
  }
  for (int i = 0; i < v.size(); ++i) {
    cout << v[i] << endl;
  }
  return 0;
}

C++: #include<iostream>
#include <cstdlib>
#include<list>
#include<string>
#include<stack>
using namespace std;
int main(){
	int a;
	stack <int> b;
	while (cin >> a) {
		if (a != 0) {
			b.push(a);
		}
		else {
			cout << b.top() << endl;
			b.pop();
		}
	}
    return 0;
}

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

using namespace std;

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