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 <bits/stdc++.h>
#include <chrono>
using namespace std;

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define endl "\n"

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        stack<_i64> vehicle; _i64 quere;
        while(cin >> quere) {
            if(quere == 0) { cout << vehicle.top() << endl; vehicle.pop(); }
            else { vehicle.push(quere); }
        }
    }
    return 0;
}

C++: // 車両入れ替え

#include <iostream>
using namespace std;

int main() {
    int pos = -1;
    int input;
    int senro[100];

    while (cin >> input) {
        if (input != 0) {
            pos++;
            senro[pos] = input;
        } else if (input == 0) {
            if (pos >= 0) {
                cout << senro[pos] << "\n";
                pos--;
            } else {
                cout << "error???" << "\n";
                return 1;
            }
        }
    }
    return 0;
}

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

using namespace std;

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

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

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

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

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