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 <algorithm>
#include<string>
using namespace std;
int top,s[10];
void push(int x){
    s[++top]=x;
}
void pop(){
    top--;
    cout<<s[top+1]<<endl;
}
int main(){
    int num;
    while(1){
        cin>>num;
        if(num==0)
            pop();
        else push(num);
    }
    return 0;
}

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

int main()
{
  int n, i = 0, j = 0;
  int car[10] = {1};
  int output[10];
  while(cin >> n){
    if(n == 0){
      if((i - 1) < 0)
	break;
      output[j] = car[i - 1];
      car[i - 1] = 0;
      i--;
      j++;
    }else{
      car[i] = n;
      i++;
    }
  }
  for(int i = 0; i < j; i++){
    cout << output[i] << endl;
  }
}

C++: #include<stdio.h>
int main(){
  int sp=0,data[9],n,i;
  for(i=0;i<100;i++){
    scanf("%d",&n);
    if(n==0){
      sp--;
      printf("%d\n",data[sp]);
    }else{
      data[sp]=n;
      sp++;
    }
  }
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <stack>

using namespace std;

int main() {

	stack<int> st;
	int a, ans[100]={0},i = 0;

	while (scanf("%d",&a),a) {
		if (a == 0) {
			ans[i] = st.top();
			st.pop();
			i++;
		}
		else {
			st.push(a);
		}
	}

	for (int j = 0; j < i; j++) {
		cout << ans[j] << endl;
	}
	return 0;
}

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

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

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

using namespace std;

void solve()
{
	stack<int> Stack;
	int num;
	while(cin >> num)
	{
		if(num == 0)
		{
			cout << Stack.top() << endl;
			Stack.pop();
		}
		else
		{
			Stack.push(num);
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

using namespace std;

int main()
{
	int a;
	stack<int> car;

	while (cin >> a){

		if (a != 0){
			car.push(a);
		}
		if (a == 0){
			cout << car.top() << endl;
			car.pop();
		}
	}

	return 0;
}

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

int main()
{
	stack<int> car;
	vector<int> outlist;

	while( !car.empty() || outlist.empty() )
	{
		int carnum;
		if(!(cin >> carnum))
		{
			break;
		}
		if(carnum)
		{
			car.push(carnum);
		}
		else
		{
			outlist.push_back(car.top());
			car.pop();
		}
	}
	
	for(size_t i=0; i<outlist.size(); ++i)
	{
		cout << outlist[i] << '\n';
	}
}

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

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

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

int main() {
  int in;
  stack<int> t;

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

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

C++: #include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <string>
#include <cmath>
#include <iomanip>

int main();


int main(){
	std::stack<int> input;		//入力される数（電車番号）を格納する
	int dummy = 0;				//ダミーナンバー

	while (std::cin >> dummy){
		if ((dummy == 0) && (!input.empty())){
			input.pop();
		}
		else if((1 <= dummy) && (dummy <= 9)){
			input.push(dummy);
		}
		else{
			//何もしない
		}
	}

	while (!input.empty()){
		std::cout << input.top() << std::endl;
		input.pop();
	}

	//while (1);
	return 0;
}

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

using namespace std;

template <typename Type>
struct print_endl : public unary_function < const Type&, void >
{
	void operator()(const Type& n)
	{
		cout << n << endl;
	}
};


int main()
{
	stack<int> s;

	vector<int> Ans;

	int temp;

	while (cin >> temp)
	{
		if (temp != 0)
		{
			s.push(temp);
		}
		else
		{
			Ans.push_back(s.top());

			s.pop();
		}

		if (s.empty())
		{
			break;
		}
	}

	for_each(Ans.begin(), Ans.end(), print_endl<int>());

	return 0;
}

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

int main() {
	int n;
	vector<int> vec;
	while (cin >> n) {
		if (n != 0) vec.push_back(n);
		else {
			cout << vec[vec.size() - 1] << endl;
			vec.pop_back();
		}
	}
	return 0;
}

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

int main(){
    stack<int> stk;
    int a;
    while(scanf("%d",&a) != EOF){
        if(a == 0){
            cout << stk.top() << endl;
            stk.pop();
        }else{
            stk.push(a);
        }
    }

    return 0;
}

C++: #include<iostream>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<algorithm>

using namespace std;

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

  while(scanf("%d", &a)!=EOF)
    {
      if(a==0)
	{
          cout<<n.top()<<endl;
          n.pop();
	}

      else
        n.push(a);
    }
}

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

std::array<u_int, 100> stack;
int point=0;

void push(int p){
	stack[point]=p;
	++point;
}

void pop(){
	--point;
	std::cout << stack[point] << std::endl;
}

int main(){
	int num;

	for(int i=0;i<100;i++){
		std::cin >> num;
		if(num == 0 && point > 0) pop();
		else push(num);
	}

    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>
#include <stack>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
// BEGIN CUT HERE
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
// END CUT HERE

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

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

  return 0;
}

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

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)


using namespace std;


int main(void)
{
    int a[202][2] ={0};
    int i = 0,j = 0,k = 0,l = 0;
    int answer[201] = {0};
    bool judge = true;
    int tempjudge = 0;
    
    while(judge)
    {
        cin >> a[i][0];
        if(a[i][0] == 0)
        {
            a[i][1] = 1;
            RFOR(j,i,-1)
                if(a[j][1] != 1 )
                {
                    answer[l] = a[j][0];
                    a[j][1] = 1;
                    cout << "ouput"<< answer[l] << endl;
                    l++;
                    break;
                }
        }
        REP(k,i+1)
        if(a[k][1] != 1){
                judge = true;
                break;
        }
        else
            judge = false;
                
        
        i++;
    }

    return 0;
}