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 <vector>
using namespace std;
int main(){
  vector<int> a;
  int n;
  while(cin >> n){
    if(n==0){
      cout<< a.back()<<endl;
      a.pop_back();//delete
    }else
      a.push_back(n);
  }
  return 0;
}

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

stack<int> st;
int main()
{
  int a;
  int train[1000];
 
  while(1)
    { cin >>a;
      if(a!=0)
	st.push(a);
      else 
	if (st.empty())
	  break;
	else{
	
	  cout <<st.top()<<"\n";
	  st.pop();}
      
    }
  
return 0;
}

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

using namespace std;

int main(){
  vector<int> rail;
  int rNum;
  while(cin >> rNum){//EOF de break
    if(rNum == 0){     
      cout << *rail.rbegin(); 
      rail.pop_back();
    }
    else  if(rNum <= 10 && rNum >= 0) rail.push_back(rNum);
  }  
  cout << endl;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
  vector<int> a;
  int n;
  while(cin >> n){
    if(n==0){
      cout<< a.back();
      a.pop_back();//delete
    }else
      a.push_back(n);
  }
  return 0;
}

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

int main()
{
	stack<int> stk;
	int n,out;

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

	return 0;
}

C++: #include <stdio.h>

int main() {
	int a,i,k,m;
	int data[15] = {0};
	int output[15] = {0};
	while(scanf("%d", &a) != EOF) {
		if (a != 0) {
			for (k = 0; k < 15; k++) {
				if (data[k] == 0) {
					data[k] = a;
					break;
				}
			}
		}
		else {
			for (k = 0; k < 15; k++) {
				if (data[k] == 0) {
					for (m = 0; m < 15; m++) {
						if (output[m] == 0) {
							output[m] = data[k - 1];
							break;
						}
					}
					data[k - 1] = 0;
					break;
				}
			}
		}
	}
	for (i = 0; i < 15; i++) {
		if (output[i] != 0) {
			printf("%d\n", output[i]);
		}
	}
	return 0;
}

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

int main(){
  int x;
  stack<int> q;
  while(scanf("%d", &x) != EOF){
    if(x == 0){
      printf("%d\n", q.top());
      q.pop();
    }
    else{
      q.push(x);
    }
  }
  return 0;
}

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


int main()
{
	int num;
	deque<int> train;
	while( cin >> num ) {
		if( num == 0 ) {	
			cout << train.back() <<endl;
			train.pop_back();
		}
		else {
			train.push_back( num );
		}
	
	}
	

	return 0;
}

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

int main(){
	int n,count = 0;
	stack<int> get;
	while(1){
		cin >> n;
		if(n==0){
			cout <<  get.top() << endl;
			get.pop();
			count -= 1;
		}
		else{
			get.push(n);
			count += 1;
		}
		if(count == 0) break;
	}
	return 0;
}

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

stack <int> st;

void enter(int car) {
  st.push(car);
}

void exit() {
  cout << st.top() << endl;
  st.pop();
}

int main() {
  int car;
  while (cin >> car) {
    if (car == 0) {
      exit();
    } else {
      enter(car);
    }
  }
}

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[101][2] ={0};
    int i = 0,j = 0,k = 0,l = 0;
    int answer[100] = {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;
                    l++;
                    break;
                }
        }
        REP(k,i+1)
        if(a[k][1] != 1){
                judge = true;
                break;
        }
        else
            judge = false;
                
        
        i++;
    }
    REP(m,l)
    cout << answer[m] << endl;

    return 0;
}

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,k;
  while(1){
    scanf("%d",&n);
    if(n==EOF)break;
    if(n==0){
      printf("%d\n",top());
      pop();
    }else{
      push(n);
    }
  }
  return 0;
}

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

int main() {
  int i;
  int cnt = 0;
  std::stack<int> st;
  while(cnt < 50) {
    scanf("%d", &i);
    if(i == 0){
      printf("%d\n", st.top());
      st.pop();
    }else{
      st.push(i);
    }
    cnt++;
  }
  return 0;
}

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

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

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

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

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    stack <int> st;
    while(cin>>n){
            if(n==0){
                if(st.empty()){
                    continue;
                }
                cout<<st.top()<<endl;
                st.pop();
            }
            else{
                st.push(n);

            }

    }


    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define M_PI 3.14159265358979
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include <algorithm>

using namespace std;

int main(){
	int n,m[100],i=0;
	while (cin >> n){
		if (n == 0){
			cout << m[i-1] << endl;
			i--;
		}
		else{
			m[i] = n;
			i++;
		}
	}
	return 0;
}

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

string str1[11],str2[11],mo;

int  s=1,t1,t2;

int main(){


    while(1){

    cin >> mo;


    if(mo!="0"){
        str1[t1]=mo;
        t1++;

    }else {
        str2[t2++]=str1[--t1];

    }

    if(t1==0)break;

    }

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

            if(str2[i]=="0")break;
        cout << str2[i] << endl;
    }


return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

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

C++: #include <stdio.h>

int main(void)
{
	int num[10];
	int in;
	int ord[10];
	int i;
	
	for (i = 0; i < 10; i++){
		num[i] = 0;
	}
	while (scanf("%d", &in) == 1){
		if (in != 0){
			for (i = 0; i < 10; i++){
				if (!num[i]){
					num[i] = in;
					break;
				}
			}
		}
		else {
			for (i = 9; i >= 0; i--){
				if (num[i] != 0){
					printf("%d\n", num[i]);
					num[i] = 0;
					break;
				}
			}
		}
	}
	
	return (0);
}