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<cstdio>
int main(void)
{
    int train[10]={0},n,count=0,outTrain[10],trainCount=0;
    while(scanf("%d",&n)!=EOF){
        if(n){
            for(int i=count ; i!=0 ; i--){
                train[i]=train[i-1];
            }
            train[0]=n;
            count++;
        }
        else{
            outTrain[trainCount]=train[0];
            for(int i=0 ; i<count ; i++){
                train[i]=train[i+1];
            }
            train[count]=0;
            count--;
            trainCount++;
        }
    }
    for(int i=0 ; i<trainCount ; i++){
        printf("%d\n",outTrain[i]);
    }
    return 0;
}

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

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

	int n;

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

	return 0;
}

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

int main(){
	int ans[11],tmp,i = 0,j,k = 0,f[11];

	while(cin>>tmp){
		if(tmp == 0){
			ans[k] = f[i-1];
			f[i-1] = '\0';
			i--;
			k++;
		}
		else{
		f[i] = tmp;
		i++;
		}
	}
	for(j = 0;j < k;j++){
		cout<<ans[j]<<endl;
	}
	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++;
		}
		if(i==0) break;
	}
	for(int n=0; n<j ; n++){
		printf("%d\n", b[n]);
	}
	
	return 0;
}

C++: /*Filename: aoj0013.cpp
 *Author: Mushiyo
 */

#include <iostream>
#include <stack>

using namespace std;

int main(){
	int num = 0;
	stack<int> car;

    while(cin >> num){
        if(num == 0){
        	cout << car.top() << endl;
        	car.pop();
        }
        else{
        	car.push(num);
        }
    }

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for (int i=n;^i;i--)
#define ALL(v) v.begin(),v.end()
// #define int ll 
#define eps 1e-9
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
typedef long long ll;

signed main(void){
	stack<int> s;
	int a;
	while(cin >> a){
		if(a==0){
			cout << s.top() << endl;
			s.pop();
		}
		else 
			s.push(a);
	}
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int train[10];
  int by[10];
  int a,i=0,j=0;
  while(scanf("%d",&a)!=EOF){
    if(a==0){
      i--;
      by[j]=train[i];
      j++;
    }
    else{
      train[i]=a;
      i++;
  }
  }
  for(int i=0;i<j;i++){
    cout<<by[i]<<endl;
  }
}

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

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

C++: #include <stdio.h>

#include <string.h>

#include <stack>

#include <iostream>


using namespace std;

int main(){
    
    int input;
    stack<int> train;
    while (scanf("%d",&input)!=EOF) {
//        scanf("%d",&input);
        if (input!=0)train.push(input);
        else {
            printf("%d\n",train.top());
            train.pop();
        }
    }
}
    //        if(strcmp(c,pu) == 0){
    //
    //            scanf("%s",&color);
    //
    //            st.push(color);
    //
    //        }
    //
    //        if(strcmp(c,po) == 0){
    //
    //            cout<<st.top()<<endl;
    //
    //            st.pop();
    //
    //        }
    //
    //        if(strcmp(c,qu) == 0){
    //
    //            return 0;
    //
    //        }
    //
    //    }
    
    //}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
	int s[10];
	int ss = 0;
	while(true) {
		int x;
		if(scanf("%d", &x)<1)break;
		if(x==0) {
			printf("%d\n",s[--ss]);
		} else {
			s[ss++]=x;
		}
	}
	return 0;
}

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 
 using namespace std;
 
 int main()
 {
   int N;
   stack<int> mystack;
   while(cin>>N)
   {
     if(N!=0) mystack.push(N);
     else
     {
       int m=mystack.top();
       mystack.pop();
       cout<<m<<endl;    
     }               
   }
   //while(1);      
   return 0;    
 }

C++: #include <stdio.h>

int train[10];
int sp = 0;

int empty() {
  return sp <= 0;
}

int size() {
  return sp;
}

int top() {
  return train[sp-1];
}

void pop() {
  sp--;
}

void push(int v) {
  train[sp] = v;
  sp++;
}

int main(){
  int out[10];
  int num, i = 0;
  while(1){
    scanf("%d", &num);
    if(num == 0){
      out[i] = top();
      i++;
      pop();
    }else if(1 <= num && num <= 10){
      push(num);
    }
    if(size() == 0) break;
  }
  for(i = 0, i < 10, i++){
    printf("%d\n", out[i]);
  }
  return 0;
}

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

int main(){
	int tmp,i = 0,j,k = 0,f[11];
	vector<int> ans;

	while(cin>>tmp){
		if(tmp == 0){
			ans.push_back(f[i-1]);
			f[i-1] = '\0';
			i--;
			k++;
		}
		else{
		f[i] = tmp;
		i++;
		}
	}
	for(j = 0;j < k;j++){
		cout<<ans[j]<<endl;
	}
	return 0;
}

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

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

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

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

C++: //include---------------------------------------------------------------------------
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cctype>
#include<ccomplex>
#include<vector>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<bitset>
#include<map>
#include<algorithm>
#include<memory>

//using namespace-------------------------------------------------------------------
using namespace std;

//define,const----------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < n; i++){
const int INF = 1 << 25;

//global----------------------------------------------------------------------------
stack<int> cars;
int numbar;

//function--------------------------------------------------------------------------
int main(){
	while(scanf("%d", &numbar) != EOF){
		if(numbar == 0){
			printf("%d\n", cars.top());
			cars.pop();
			continue;
		}
		cars.push(numbar);
	}
	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; train[i] != 0; i++) {i+1;}
			junban[a] = train[i - 1];
			train[i - 1] = 0;
			a++;
		}
		else {
			for (i = 0; train[i] != 0; i++) {i+1;}
			train[i] = n;
		}
	}
	for (i = 0; junban[i] > 0; i++) {
		cout << junban[i] << endl;
	}
	return 0;
}