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>
using namespace std;
class Stack_10{
private:
	int num;
	int x[10];
public:
	Stack_10(){num=0;};
	void push(int i){
		if(num<10){			
			x[num]=i;
			num++;
		}
	};
	int pop(){
		if(num>0){
			num--;
			return x[num];
		}
		else return -1;
	
	};
};
	
int main(int argc, char *argv[]){
	int car;
	Stack_10 stack;
	while(cin>>car){
	if(car>0) stack.push(car);
	else cout<<stack.pop()<<endl;
}

	return 0;
}

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


int main(){
    using namespace std;

    stack<int>s;
    do{
        int n;
        cin>>n;
        if(n!=0){
            s.push(n);
        }else{
            cout<<s.top()<<endl;
            s.pop();
        }
    }while(s.size()!=0);
    
    return 0;
}

C++: //#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
  int car[100];
  int n,i=0;
  while(cin>>n){
    if(n==0){
      cout<<car[i]<<endl; i--;
    }
    else {
      i++; car[i]=n;
    }
  }
  return 0;
}

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


int main(){

  int train[10] , num[10];

 for( int i = 0; i < 10; i++ ){
    train[i] = 0;
    num[i] = 0;
 }

  for( int i = 0; i < 10; i++ ){

    cin >> train[i];

    if( train[i] == 0 ){
      for( int j = i; j >= 0; j-- ){
	if( train[j] != 0 ){
	num[i] = train[j];
	train[j] = 0;
	break;
	}
      }
    }
  }
  

  for( int k = 0; k < 10; k++ ){
    if( num[k] != 0 ) cout << num[k] << endl; 

  }


  return 0;
}

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

int main(){
	
	int no;

	stack<int> st;
	
	do{
		cin >> no;
		
		if(no == 0){
			cout << st.top() << endl;
		    st.pop();
		}else{
			st.push(no);
		}
		
	}while(st.empty() == false);
	
	return 0;
}

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

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

C++: //Vol0 0013
#include<stdio.h>
int main()
{
	int n,buf[128]={0},i=0;
	while(!(scanf("%d",&n)==EOF)){
		if(n==0){
			if(i!=0){
				i--;
			}
			printf("%d\n",buf[i]);
			buf[i]=0;
		}else{
			buf[i]=n;
			i++;
		}
	}
	return 0;
}

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

using namespace std;

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

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

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

C++: #include<iostream>

using namespace std;

int main() {
	int train[20] = { 0 }, junban[20] = { 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;
}

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

using namespace std;

int n;
int a[10];
int i = 0;

int main()
{
	stack<int> s;
	while(scanf("%d", &n) != EOF){
		if(n == 0){
			a[i] = s.top();
			s.pop();
			i++;
		}
		else{
			s.push(n);
		}
	}
	
	for(int j = 0; j < i; j++){
		printf("%d\n", a[j]);
	}
	
	return 0;
}

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

using namespace std;

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

C++: #include <iostream>

using namespace std;

int main(){
    int track[10], c, num;
    while(1){
        cin >> num;
        if(!num){
            if(!c) cout << "No train" << endl;
            else cout << track[c--] <<endl;
        }
        else{
            if(c==10) cout << "Already Full" <<endl;
            else track[++c] = num;
        }
    }
    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 <iostream>
#include <stack>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  int car;
  stack<int> st;
  vector<int> result;

  while (cin >> car) {
    if (car == 0) {
      result.push_back(st.top());
      st.pop();
    } else {
      st.push(car);
    }
  }

  for (int i = 0; i < result.size(); i++)
    cout << result[i] << endl;
  for (int i = 0; i < st.size(); i++) {
    cout << st.top() << endl;
    st.pop();
  }
  return 0;
}

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

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

C++: #include<iostream>
#include<vector>
#include<string>
#include<math.h>
using namespace std;

int main()
{
	while(true)
	{
	vector<int>a;
	vector<int>b;
	vector<int>c;
	int s[20];

for(int i=0;i<20;i++)
{
	cin>>s[i];

if(s[i]==0)
	{
		b.push_back(s[i]);
		a.push_back(c.back());
		c.pop_back();
		if(c.size()==0)
		{
		break;
		}
	}
	else
	{
		c.push_back(s[i]);
	}
	
}
for(int j=0;j<a.size();j++)cout<<a[j]<<endl;
	}
return 0;


}

C++: #include<bits/stdc++.h>
using namespace std;
stack<int> s;
signed main(void){
	ios::sync_with_stdio(false);
	int x;
	while(cin>>x){
		if(x)
			s.push(x);
		else{
			cout<<s.top()<<endl;
			s.pop();
		}
	}
}

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

using namespace std;

int main(void){
	stack<int> st;
	int n,a;

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

C++: #include<iostream>
#include<cstdio>
#include<stack>
using namespace std;
int main()
{
	int n;
	int i;
	stack<int> in;
	while(scanf("%d",&i) != EOF){
		if(i != 0){
			in.push(i);
		}
		else {
			cout << in.top() << endl;
			in.pop();
		}
	}
}

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

int main()
{
  stack<int> trains;
  int i;
  do
  {
    cin >> i;
    if (i != 0) trains.push(i);
    else
    {
      cout << trains.top() << endl;
      trains.pop();
    }
  } while (!trains.empty());
  return 0;
}

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

using namespace std;

int main(){
    int a;
    vector<int> buffer;
    while(cin >> a){
        if(a == 0){
            cout << buffer.back() << endl;
            buffer.pop_back();
        }
        else{
            buffer.push_back(a);
        }
    }
}

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

int main()
{
	int n;
	int pop_car[1024];
	int cnt = 0;
	stack<int> car;

	while (cin >> n){
		if (n == 0){
			pop_car[cnt] = car.top(); // top pop
			car.pop();
			cnt++;
		}
		else {
			car.push(n);
		}
	}

	for (int i = 0; i < cnt; i++){
		cout << pop_car[i] << endl;
	}

	return (0);
}