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<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int tmp = 0;
	deque<int>A;
	while (cin >> tmp) {
		if (tmp == 0) {
			cout << A.front() << endl;
			A.pop_front();
		}
		else {
			A.push_front(tmp);
		}
	}
}

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

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

int main()
{
  int n, i = 0, j = 0;
  int car[10] = {1};
  int output[10];
  while(cin >> n){
    if(n == 0){
      output[j] = car[i - 1];
      car[i - 1] = 0;
      i--;
      j++;
      if(car[0] == 0)
	break;
    }else{
      car[i] = n;
      i++;
    }
  }
  for(int i = 0; i < j; i++){
    cout << output[i] << endl;
  }
}

C++: #include <bits/stdc++.h>
#include <vector>
using namespace std;
int x, lol;
vector<int> vec;

int main(){
	lol = 0;
	while(cin >> x){
		if(x == 0){
			cout << vec[lol-1] << "\n";
			vec.erase(vec.begin()+(lol-1));
			lol--;
		}
		else{
			vec.push_back(x);
			lol++;
		}
	}
	
	
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

stack<int> cars;

int main() {
	int input = -1;

	cin >> input;
	while (input != -1) {
		if (input > 0) {
			cars.push(input);
		} else {
			cout << cars.top() << endl;
			cars.pop();
		}

		input = -1;
		cin >> input;
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

C++: #include <iostream>

using namespace std;

int main(){
    int track[10], c, num;
    while(1){
        cin >> num;
        if(!num){
            if(!c) break;
            else cout << track[c--] <<endl;
        }
        else{
            if(c==10) cout << "Already Full" <<endl;
            else track[++c] = num;
        }
    }
    return 0;
}

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

int main(){
	std::stack<int> st;
	int num;
	
	while(std::cin >> num){
		if(num == 0){
			std::cout << st.top() << std::endl;
			st.pop();
		}else{
			st.push(num);
		}
		if(st.empty()){
			break;
		}
	}
	
    return 0;
}

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

using namespace std;

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

    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
    int a,c,i;
    vector<int> s;
    vector<int> t;
    while(cin>>a){
        c=s.size();
        if(a!=0){
            s.push_back(a);
        }
        else if(a==0&&c>0){
            s.pop_back();
            t.push_back(s[s.size()-1]);
            s.pop_back();
        }
    }
    int b=t.size();
    for(i=0;i<b;i++){
        cout << t[i] << endl;
    }
    return 0;
}

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

int main()
{
	stack<int> s;
	deque<int> ans;
	int n;

	while (1)
	{
		cin >> n;
		if (n == 0)
		{
			ans.push_front(s.top());
			s.pop();
			if (s.empty()) break;
		}
		else
		{
			s.push(n);
		}
	}

	while (1)
	{
		if (!ans.empty())
		{
			cout << ans.back() << endl;
			ans.pop_back();
		}
		else break;
	}
	return 0;
}

C++: #include<stdio.h>

int main(){
  int i = 0, x;
  int data[100];
  scanf("%d", &x);
  while(x != EOF){
    scanf("%d", &x);
    if(x != 0){
      data[i] = x;
      i++;
    }else{
      printf("%d\n", data[i-1]);
      i--;
    }
  }
  return 0;
}

C++:  /*
This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks.

We can simulate the movement (comings and goings) of the cars as follow:

An entry of a car is represented by its number.
An exit of a car is represented by 0
For example, a sequence

1 6 0 8 10
demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter.

Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks.
 */
 
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	vector<int> cars(100000), ans;
	int temp, i=0, m;
	while (cin >> temp) {
		if (temp != 0) {
			cars[i] = temp;
			i++;
		} else {
			int p = i-1;
			if (p < 0) {
				ans.push_back(cars[p]);
				i--;
			}
		}
	}
	for (int j=0; j<ans.size(); j++)
		cout << ans[j] << endl;
	return 0;
}

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

int main(int argc,char* argv[]){
  std::stack<int> vec;
  
  while(!std::cin.eof()){
    int temp;
    std::cin >> temp;
    if(temp == 0){
      std::cout << vec.top() << std::endl;
      vec.pop();
      continue;
    }else{
      vec.push(temp);
      continue;
    }
  }

  return 0;
  
}

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

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

int main(){
    u_int a, end = 0;
    std :: vector<int> v = {};
    while(std :: cin >> a){
        if(a == 0){
            std :: cout << v.at(end-1) << std :: endl;
            v.pop_back();
            end--;
        } else{
            v.push_back(a);
            end++;
        }
    }
}

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

int main(void){
  stack<int> data;
  int a;

  while(scanf("%d",&a) != EOF){
    if(a) data.push(a);
    else {
      if(data.empty()) break;
      printf("%d\n",data.top());
      data.pop();
    }
  }

  return 0;
}