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<cstdio>
#include<cstring>
#include<stack>
using namespace std;

int main(){
   int i=0,n,m,x;
   int syaryo[999];
   stack<int>st;
   cin>>n;
   st.push(n);
   
   while(1){
      if(st.empty())
         break;
      cin>>n;
      if(n==0){
         m = st.top();
         st.pop();
         syaryo[i] = m;
         i++;
      }
      else
         st.push(n);
   }
   for(x=0;x<i;x++) printf("%d\n",syaryo[x]);
     
   return 0;
}

C++: #include <stdio.h>

int main() {
	int a,i,k,m;
	int data[15] = {0};
	int output[15] = {0};
	while(scanf("%d", &a) != EOF) {
		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;
				}
			}
		}
	}
	for (i = 0; i < 15; i++) {
		if (output[i] != 0) {
			printf("%d\n", output[i]);
		}
	}
	return 0;
}

C++: #include<stdio.h>

int main(){
	int car[11],i=0,n;
	do{
		scanf("%d",&n);
		if(n){
			car[i]=n;
			i++;
		}else{
			i--;
			printf("%d\n",car[i]);
			
		}
	}while(i>0);
}

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

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

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

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

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

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

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

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

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

struct stack{
	int element;
	struct stack *next;
};
int top(struct stack *s){
	return s->element;
}
struct stack* pop(struct stack *s){
	struct stack *p, *q;
	q = s;
	p = s->next;
	free(q);
	s = p;
	return s;
}
struct stack* push(struct stack *s, int x){
	struct stack *p, *q;
	q = s;
	p = (struct stack*)malloc(sizeof(struct stack));
	p->element = x;
	p->next = q;
	s = p;
	return s;
}

int main(){
	struct stack *S=NULL;
	int num;
	while (cin>>num){	
		if (num==0){
			cout<<top(S)<<endl;
			S = pop(S);
		} else{
			S=push(S, num);
		}
	}
	return 0;
}

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

int main() {
	int n;
	while (cin >> n) {
		int ans = 0;
		for (int i = 0; i < 600 / n; i++) {
			ans += 600/n*i;
		}
		ans *= 600 / n;
		cout << ans << endl;
	}
}

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

int main() {
	std::list<int> cars;
	int n;
	while (std::cin >> n) {
		if (n != 0) {
			cars.push_back(n);
		}
		else {
			std::cout << cars.back() << std::endl;
			cars.pop_back();
		}
	}
	return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int x;
  stack<int> s;
  queue<int> q;
  while (cin >> x) {
    if (x == 0) {
      q.push(s.top());
      s.pop();
    } else {
      s.push(x);
    }
  }
  for (; q.size(); q.pop()) cout << q.front() << endl;
}

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

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

int main(void){
    int n;
    stack<int> s;
    while(scanf("%d",&n)!=EOF){
        if(n!=0) s.push(n);
        else{
            cout << s.top() << "\n";
            s.pop();
        }
    }
}

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

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

 	return 0;
}

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

  while( scanf("%d",&num) != EOF ){

    if( num != 0 ){
      a[c]=num;
      c++;
    }else{
      cout <<a[c-1]<<endl;
      c--;
    }   

  }
  return 0;

}

C++: #include <stdio.h>

#define N 20
int main(void){
    int stk[N], sp=0;
    int n;
   
    while (scanf("%d", &n)){
        if (n==0 && sp!=0){
            printf("%d\n", stk[--sp]);
        } else {
            stk[sp++] = n;
        }
    }
    return 0;
}

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

int main(void) {
    u_int in;
    std::stack<u_int> st;

    while (std::cin >> in) {
        if (in > 0) {
            st.push(in);
        } else {
            std::cout << st.top() << std::endl;
            st.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 <iostream>
#include <stack>


using namespace std;

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