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;
#define N 1000

int main()
{
	int x;
	int stack[N];
	int n = 0;
	
	while (cin >> x) {
		if (x != 0) {
			stack[n] = x;
			n++;
		} else {
			cout << stack[n - 1] << "\n";
			n--;
		}
	}
	return 0;
}

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

int main()
{
	stack<int> train ;
	int i ;

	while( cin >> i )
	{
		if( i != 0 )
		{
			train.push(i) ;
		}
		else
		{
			cout << train.top() << "\n" ;
			train.pop() ;
		}
	}
	return 0 ;
}

C++: #include<iostream>
#include<stack>
using namespace std;
int main(){
  stack<int> chu;
  int i=0;
  int input;
  cin>>input;
  chu.push(input);
  while(!chu.empty()){
    cin>>input;
    if(input!=0){
      chu.push(input);
    }else{
      cout<<chu.top()<<endl;
      chu.pop();
    }
  }
}

C++: /*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

int main() {
	int num;
	vector<int> stack;
	while (cin >> num)
	{
		if (num == 0)
		{
			// ??????????????????????????????????¶????
			cout << stack.back();
			stack.pop_back();
			continue;
		}
		// ???????????????????????°????????\??????
		stack.push_back(num);
	}
	return 0;
}

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

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    std::stack<long long int> s;

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

    return 0;
}

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

using namespace std;

int main() {
	int b;
	int a[10] = {0};

	while (cin >> b) {
		if (b == 0) {
			for (int i = 9; i >= 0; i--) {
				if (a[i] != 0) {
					cout << a[i] << endl;
					a[i] = 0;
					break;
				}
			}
		} else {
			for (int i = 0; i < 10; i++) {
				if (a[i] == 0) {
					a[i] = b;
					break;
				}
			}
		}
	}
	return 0;
}

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

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

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

int main() {
	int n, count = 0, a[10], i;
	stack<int> s;
	while (cin >> n,n>=0,!cin.eof()) {
		if (n > 0) s.push(n);
		else if (n == 0) { a[count] = s.top(); s.pop(); count++}
	}
	for (i = 0; i < count; i++) {
		cout << a[i] << endl;
	}
}

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

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	stack<int> s;
	int n;
	while(1) {
		if(scanf("%d", &n) == EOF) break;
		if(n > 0) {
			s.push(n);
		} else if(n == 0) {
			if(!s.empty()) {
				cout << s.top() << endl;
				s.pop();
			}
		}
	}
}

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

int main(){

	std::stack<int> train;
	int buf;

	while(std::cin >> buf){

		if(buf == 0){

			std::cout << train.top() << std::endl;
			train.pop();

		}else{
			train.push(buf);
		}
	}
	return 0;
}

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

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

using namespace std;



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

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

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

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

int main(){
	vector<int> car, exit;
	int n;
	
	while( cin >> n ){
		
		if(n != 0){
			car.push_back(n);
		}else{
			exit.push_back( car.back() );
			car.pop_back();
		}
	}
	vector<int>::iterator it = exit.begin();

	while( it != exit.end() ){
		cout << *it << endl;
		++it;
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 1000000001
#define EPS 1.0e-6

using namespace std;

typedef long long ll;

int main()
{
	stack<int> s;

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

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n, train[100]={}, max=0;
    while(cin >> n){
        if(n != 0){
            for(int i=max; i>=0; i--){
                train[i+1]=train[i];
            }
            train[0]=n;
            max++;
        }
        else if(n == 0){
            cout << train[0] << endl;
            for(int i=1; i<=max; i++){
                train[i-1]=train[i];
            }
            max--;
        }
    }
    return 0;
}

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

int main(){
	stack<int> st;
	queue<int> q;
	int input;

	cin >> input;
	st.push(input);
	while(!st.empty()){
		cin >> input;
		if(input == 0){
			q.push(st.top());
			st.pop();
		}
		else{
			st.push(input);
		}
	}
	while(!q.empty()){
		cout << q.front() << endl;
		q.pop();
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(void)
{
    vector<int> t;
    int a;
    do
    {
        cin >> a;
        if (a != 0)
        {
            t.push_back(a);
        }
        else if (a == 0)
        {
            cout << t.back() << endl;
            t.pop_back();
        }
    } while (true);
}

C++: #include <iostream>
#include <stack>
using namespace std;
int main( void )
{
	int n;
	stack <int> S;

	while ( cin >> n )
	{
		if ( n == 0 )
		{
			cout << S.top() << endl;
			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){
            st.push(n);
        }else{
            cout << st.top() << endl;
            st.pop();
        }
    }
    return 0;
}

C++: /*AOJ 0013*/

#include<iostream>
#include<stack>

using namespace std;

int main(){

	stack<int> data;

	int tmp;

	cin>>tmp;

	data.push(tmp);

	int flag = 0;
	for(;;){

		flag = 0;

		cin>>tmp;

		if(tmp == 0){
			cout<<data.top()<<endl;
			data.pop();
			if(data.size()==0){
				flag = 1;
			}
		}
		else{
			data.push(tmp);
		}

		if(flag == 1){
			break;
		}
	}
	return 0;
}