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<stdio.h>
const int SIZE=100;
int data[SIZE];
int sp=0;
int size(){
  return sp;
}
int empty(){
  return sp<=0;
}
int top(){
  return data[sp-1];
}
void pop(){
  sp--;
}
void push(int v){
  data[sp]=v;
  sp++;
}
int main(){
  int n,k;
  while(scanf("%d",&n)!=EOF){
    if(n==0){
      printf("%d\n",top());
      pop();
    }else{
      push(n);
    }
  }
  return 0;
}

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

int main()
{
	stack<int> car;
	vector<int> outlist;

	while( !car.empty() || outlist.empty() )
	{
		int carnum;
		cin >> carnum;
		if(carnum)
		{
			car.push(carnum);
		}
		else
		{
			outlist.push_back(car.top());
			car.pop();
		}
	}

	for(size_t i=0; i<outlist.size(); ++i)
	{
		cout << outlist[i] << '\n';
	}
}

C++: // 2011/06/04 Tazoe

#include <iostream>
#include <stack>
using namespace std;

int main()
{
	stack<int> st;

	while(true){
		int n;
		cin >> n;
		if(cin.eof())
			break;

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

	return 0;
}

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

int main(void){
	double n;
	stack <double> buf;

	while (true){
		cin>>n;
		if (cin.eof()) break;

		if (n!=0) buf.push(n);
		else{
			cout<<buf.top();
			buf.pop();
		}
	}
    return 0;
}

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

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

C++: #include<iostream>

using namespace std;

int main() {
	int train[11] = { 0 }, junban[11] = { 0 }, a = 0, n, i;	
	while (cin >> n) {
		if (n == 0) {
			for (i = 0; i <= 10 && train[i] != 0; i++) {;}
			junban[a] = train[i - 1];
			train[i - 1] = 0;
			a++;
		}
		else {
			for (i = 0; i <= 10 && train[i] != 0; i++) {;}
			train[i] = n;
		}
	}
	for (i = 0; i <= 10 && junban[i] > 0; i++) {
		cout << junban[i] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<math.h>

using namespace std;
#define C(_Str) cout << _Str << endl
typedef long long int lli;

int main()
{
	int Num,i=0,j=0,k=0;
	vector<int> Car(100);
	vector<int> Out(100);
	while (cin >> Num) {
		
		if (Num != 0) {
			Car[i] = Num;
			i++;
		}
		else {
			i--;
			Out[j] = Car[i];
			j++;
		}
	}
	while (Out[k]) { 
		cout << Out[k] << endl;
		k++;
	}
	return 0;
}

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

using namespace std;

stack<int>s;
int cou[100];
int c=0;

int main(){
   
    do{
        int n;
        cin>>n;
        if(n){
            s.push(n);
        }else{
            //cout<<s.top()<<endl;
            cou[c]=s.top();
            s.pop();
            c++;
        }
    }while(s.size());
    
    for(int i=0;i<c;i++){
        cout<<cou[i]<<endl;
    }
    
    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<queue>
#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(){
  int in;
  queue<int>out;
  while(cin>>in){
    if(in)out.push(in);
    else {
      cout<<out.front()<<endl;
      out.pop();
    }
  }


}

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

int main(){

	int in;
	stack<int> st;

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

}

C++: #define scanf_s scanf
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 150
int main(void)
{
	int n, now = 0;
	int list[MAX] = { 0 };
	while(scanf_s("%d", &n) != EOF){
		if (n != 0) { list[now] = n; ++now; }
		else { --now; 	printf("%d\n", list[now]);}
	}
}

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

int main(){
stack<int>a;
int b;
scanf("%d",&b);
a.push(b);
while(cin>>b){
	if(b)a.push(b);
	else {printf("%d\n",a.top());a.pop();}
}
}

C++: #include<stdio.h>
int main(){
	int a,b,c,d,train[100];
	b=0;
	c=0;
	
	int g;
	int cont = 0;
	
	for(a=0;a<1000;a++){
		if(scanf("%d",&g)==-1){
			break;
		}
		
		if(g != 0){
			train[cont] = g;
			cont++;
		}
		else{
			printf("%d\n",train[cont-1]);
			cont--;
		}
		/*
		if(cont == 0){
			break;
		}
		*/
		/*
		if(train[a]==0){
			c++;
		}else{
			b++;
		}
		if(b==c){
		break;
		} 
		*/
	}
	return 0;
}

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