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>
#include<stack>
using namespace std;
int main(){
		stack<int>s;
		int a;
		while(cin>>a){
				if(a==0){
						//if(s.size()==0)break;
						cout<<s.top()<<endl;
						s.pop();
				}
				else{
						s.push(a);
				}
		}
		return 0;
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>


using namespace std;

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

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

using namespace std;

int main()
{
	stack<int> hako;
	int temp[100];
	int input[100];
	int t, i = 0, k = 0;
	
	
	while(cin>>t){
		input[i] = t;
		i++;
	}
	
	/*
	while(1){
		cin >> t;
		if( t == -1){
			break;
		}
		input[i] = t;
		i++;
	}
	*/
	for(int j = 0; j < i; j++){
		if(input[j] == 0){
			temp[k] = hako.top();
			hako.pop();
			k++;
		}
		else{
			hako.push(input[j]);
		}
	}
	
	for(int j = 0; j < k; j++){
		cout << temp[j] << endl;
	}
	
}

C++: #include <stack>
#include <iostream>
 
using namespace std;
 
int main(void){
        int tem;
        stack<int> st;
        cin >> tem;
        st.push(tem); 
        while(true){
                cin >> tem;
                if( cin.eof())
                        break;
                if(tem)
                        st.push(tem);
                else{
                        cout <<st.top()<<endl;
                        st.pop(); 
                }
        }
return 0;
}

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

stack<int> sta;

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

C++: #include <stdio.h>
 
int main(void) {
  std::stack<int> st;
  int n;
  while(scanf("%d", &n) != EOF) {
    if(n) st.push(n);
    else {
      printf("%d\n", st.top());
      st.pop();
    }
  }
  return 0;
}

C++: #include <stdio.h>

int main() {
	int temp[10];
	int input;

	int i = 0;
	
	while(scanf("%d", &input) != EOF) {
		if(input != 0) {
			temp[i] = input;
			i++;
		}

		else {
			i--;
			printf("%d\n", temp[i]);
		}
	}

	return 0;
}

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

C++: #include<iostream>
using namespace std;
class stack{
	int row[10];
	int top;
	public:
		stack(){top = 0;}
		void push(int x);
		int pop();
};
void stack::push(int x){
	row[top] = x;
	top++;
}
int stack::pop(){
	top--;
	return row[top];
}
int main(){
	stack cars;
	int k;
	while(cin >>k){
		if(k == 0){cout<<cars.pop()<<endl;}
		else{cars.push(k);}
	}
	return 0;
}

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

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

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

using namespace std;

int main(int argc, char const *argv[]){
    int input; 
    stack<int> train_stack;
    vector<int> order;

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

    return 0;
}

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

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

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

using namespace std;

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

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

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

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int main(){
    stack<int> densha;
    for(int a; cin >> a; ){
        if(a == 0){
            cout << densha.top() << endl;
            densha.pop();
        }else
          densha.push(a);
    }
    return 0;
}

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

int main( void )
{
	stack <int> S;
	int first;
	cin >> first;
	S.push( first );

	string kotae = "";
	while ( S.empty() == false )
	{
		int n;
		cin >> n;
		if ( n == 0 )
		{
			ostringstream os;
			os << S.top() << endl;
			kotae += os.str();
			S.pop();
		}
		else
		{
			S.push( n );
		}
	}

	cout << kotae;

	return 0;
}

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

bool listen_input(int &);

void exec_order(std::stack<int> &,const int);

//--------------------main-------------------------
int main()
{
	using namespace std;
	
	stack<int> carStop;
	
	int order;
	while(listen_input(order))
	{
		exec_order(carStop,order);
	}
	
	return 0;
}
//-------------------------------------------------

bool listen_input(int &order)
{
	using namespace std;
	
	cin>>order;
	if(cin.eof())
	{
		return false;
	}
	else
	{
		return true;
	}
}

void exec_order(std::stack<int> &carStop,const int order)
{
	using namespace std;
	
	if(order)
	{
		carStop.push(order);
	}
	else
	{
		cout<<carStop.top()<<endl;
		carStop.pop();
	}
}

C++: #include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    int car[105];
    int num;
    int i=0;
    while(1){
        cin>>num;
        if(num!=0){
            car[i]=num;
            i++;}
        else{
            i--;
            cout<<car[i]<<endl;
            car[i]=0;
        }
    }
    return 0;
}

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

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

	//car's number
	int num = 0;

    //Until the end of input
	while(std::cin >> num){
        //if num = 0, output and delete
		if(num == 0){
			std::cout << st.pop() << std::endl;
        //if num != 0, input    
		} else {
			st.push(num);
		}
	}
}

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

C++: #include <cstdio>

int stack[10];
int cur = 0;

void push(int x){
	stack[cur] = x;
	cur++;
}

int pop(){
	cur--;
	return stack[cur];
}

int main(){
	int n;
	
	scanf("%d", &n);
	push(n);
	for(;;){
		scanf("%d", &n);
		if(n == 0){
			printf("%d\n", pop());
		}else {
			push(n);
		}
		if(cur == 0) break;
	}
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	stack<int> st;
	int x;
	while (cin >> x) {
		if (x == 0) {
			cout << st.top(); st.pop();
		}
		else st.push(x);
	}
}