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 <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.src", "r", stdin);
	string str = "";
	stack <int> R;

	while ( getline (cin, str )){
		int n;
		stringstream ss(str);
		ss >> n;
		if (n != 0){
			R.push(n);
		}else if (n == 0 && !R.empty()){
			cout << R.top() << endl;
			R.pop();
		} // end if
	} // end for

	return 0;
}

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

int main(){

    std::vector<int> vehicle_order;
    int input_data;

    while(std::cin >> input_data){
        if(input_data == 0){
            std::cout << vehicle_order.back() << std::endl;
            vehicle_order.pop_back();
        }else{
            vehicle_order.push_back(input_data);
        }
    }

    return 0;
}

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

int main(){
	
	int num,in;
	while(cin>>in){
		if(in == 0){
			cout<<num<<endl;
		}else{
			in=num;
		}
	}
	return 0;
	
}

C++: #include "stdio.h"
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

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

    while (~scanf("%d", &input)){
        if (input==0){
            cout<<train_stack.top()<<endl;
            train_stack.pop();
        }
        else{
            train_stack.push(input);
        }
    }
    return 0;
}

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

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

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

int main(void)
{
	stack<int> s;
	int zug;

	while (cin >> zug) {
		if (zug > 0) s.push(zug);
		else {
			cout << s.top() << endl;
			s.pop();
		}
	}
	
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<stdio.h>
using namespace std;
int main(){
  int train[10],n,i;
  n = 0;
  int order[100],intrain[10];
  for( i = 1;i <= 10;i++){
    train[i] = i;
  }
  for(i=0;i<20;i++)
    order[i] = 11;
  i = 0;
  while(scanf("%d",&order[i]) != EOF){i++;}
  for(i = 0;order[i] != 11;i++){
    if(order[i] != 0){
      intrain[n] = order[i]; n++;}else if(order[i] == 0){
      n--;      cout << intrain[n] << endl;}
  }
}

C++: /*****include*****/
#include <iostream>
#include <fstream>
#include <list>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****変数置き場*****/
	list<int> V;
	int order;
	/*****処理部*****/
	while(1){
		cin >> order;
		if(order == 0){
			cout << V.back() << endl;
			V.pop_back();
		}else{
			V.push_back(order);
		}
	}
	return 0;
}

C++: #include<stdio.h>
const int SIZE=100;
int data[SIZE]={0};
int sp=0;
int size(){
  return sp;
}
int empty(){
  return sp<=0;
}
int isfull(){
  return sp>=SIZE;
}
int top(){
  return data[sp-1];
}
void pop(){
  sp--;
}
void push(int v){
  data[sp]=v;
  sp++;
}
int main(){
  int k,n;
  for(k=0;k<100;k++){
    scanf("%d",&n);
    if(empty()&&n==0)break;
    if(!empty()&&n==0){
      printf("%d\n",top());
      pop();
    }else if(!isfull()){
      push(n);
    }
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int a[101],b[101];
int main()
{
	int i=1,j,n,s=1;
	bool yes;
	while(cin>>a[i])
	{
		if(a[i]==0)
		{
			j=i-1;
			yes=true;
			while(yes==true)
			{
				if(a[j]!=0)
				{
					b[s]=a[j];
					a[j]=0;
					s++;
					yes=false;
				}
				j--;
			}
		}
		i++;
	}
	for(i=1;i<s;i++)cout<<b[i]<<endl;
	return 0;
}

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

int main(void){
	stack<int> s;

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

C++: #include<iostream>
int main(){
	int n,sp=0,st[10];
	while(std::cin>>n)
		if(n)st[sp++]=n;
		else std::cout<<st[--sp]<<std::endl;
	return 0;
}

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

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  stack<int> a;
  queue<int> ans;
  int box;
  while(1){
    cin >> box;
    if(box){
      a.push(box);
    }else{
      ans.push(a.top());
      a.pop();
    }
    if(a.empty())break;
  }
  while(1){
    cout << ans.front() << endl;
    ans.pop();
    if(ans.empty())break;
  }
}

C++: #include <bits/stdc++.h>
using  namespace std;
#define ll    long long int
#define pai     pair<int,int>
#define vi      vector<int>
#define vd      vector<double>
#define mpi     map<int,int>
#define mps     map<string,int>
#define sti     stack<int>
#define stc     stack<char>
#define sei     set<int>
#define ses     set<string>
#define multii  multiset<int>

 int main()
{
sti s;
vi v;
ll x;
while(cin>>x){
if(x==0){
    v.push_back(s.top());
    s.pop();
}
else{
  s.push(x);
}
}
for(int i=0;i<v.size();i++){
   cout<<v[i]<<endl;
}

}

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

int
main(void)
{
	char line[80];
	int m;
	std::stack<int> s;

	while (fgets(line, sizeof line, stdin)) {
		if (sscanf(line, "%d", &m) == 1) {
			if (m == 0) {
				printf("%d\n", s.top());
				s.pop();
			} else {
				s.push(m);
			}
		}
	}

	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int main(int argc, char const *argv[])
{
	stack<int> st;
	int i;
	while(scanf("%d", &i) != EOF)
	{
		if (i == 0)
		{
			printf("%d\n", st.top());
			st.pop();
		}
		else
		{
			st.push(i);
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int i=0,num,a[10],x=0;
  
  while(cin>>num){
    if(num==0){
      cout<<a[i-1]<<endl;
      i--;
    }
    else  a[i++]=num;
    if(!i)break;
  }
  
    return 0;
}

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

using namespace std;

int main(void){
	int num;
	stack<int> train;

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

	return 0;
}

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

int main() {

	std::stack<int> st;
	int inp;//input

	while (std::cin >> inp)
	{
		if (inp == 0) {//output data and pop data
			std::cout << st.top() << std::endl;
			st.pop();
		}
		else {//push data
			st.push(inp);
		}
	}

	return 0;
}