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;
int main() {
	int n,oki[1111],ok,ans[11111],an;
	ok = 0;
	an = 0;
	while(cin >> n) {
		if (n == 0) {
			an = an + 1;
			ans[an] = oki[ok];
			ok = ok - 1;
		}
		else {
			ok = ok + 1;
			oki[ok] = n;
		}
	}
	for (int i = 1; i <= an; i++) {
		cout << ans[i] << endl;
	}
}

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

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

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

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

C++: #include<iostream>
using namespace std;
int main(){
  int number,count1,count2,enter[11],leave[11],sum;
  sum=0;
  count1=0;
  count2=0;
  while(1){
    cin >> number;
    if(number!=0){sum++;
      enter[count1]=number;
      count1++;}
    else if(number==0){
      count1--;
      leave[count2]=enter[count1];
      count2++;}
    if(sum-1<count2)break;
			}
  for(int i=0;i<count2;i++){
    cout << leave[i]<< endl;
  }
 
  return 0;
  }

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

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

C++: #include<cstdio>
#include<stack>
using namespace std;
int main(){
    int a;
    stack<int> st;
    while(~scanf("%d",&a)){
        if(a) st.push(a);
        else{
            printf("%d\n",st.top());
            st.pop();
        }
    }
}

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

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

int main(void){
	std::vector<int> trainID; //list of inputted trainID
	int tmp;

	std::cin >> tmp; //input trainID
	trainID.push_back(tmp); //add trainID

	while(std::cin >> tmp){  //input trainID or 0
		if(tmp == 0){
			std::cout << trainID.back() << std::endl; //output last trainID
			trainID.pop_back(); //delete outputted trainID
		}else{
			trainID.push_back(tmp); //add trainID
		}
	}

	return 0;
}

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){
      printf("%d\n",data[sp]);
      sp--;
    }else{
      sp++;
      data[sp]=n;
    }
  }
}

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

int main(){
    
	using namespace std;
	
	int a;
	int i,j;
	stack<int> s;
	
	while(scanf("%d",&a)!=-1){
		if(a==0){
			
			cout<<s.top()<<endl;
			s.pop();
		}
		else{
			
			s.push(a);
		}
	
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

#define MAX 1000000

using namespace std;

int main()
{
	vector<int> input;
	int n;

	while(cin>>n){
		if(n==0){
			cout<<input[input.size()-1]<<endl;
			input.pop_back();
		}
		else input.push_back(n);
	}

	return 0;
}

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

int main()
{
  vector<int> train;
  int in;
  while(cin>>in){
    if(in){
      train.push_back(in);
    }
    else{
      cout << train.back() << endl;
      train.pop_back();
    }
  }
  return 0;
}

C++: #include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#include<stack>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;


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

C++: #include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
using namespace std;

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

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

using namespace std;

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

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

C++: #include<stdio.h>
int main(){
	int a,b,c,d,train[100],memory[100];
	b=0;
	c=0;
	
	int g;
	int cont = 0;
	
	for(a=0;a<100;a++){
		scanf("%d",&g);
		
		if(g != 0){
			train[cont] = g;
			cont++;
		}
		else{
			printf("%d\n",train[cont-1]);
			cont--;
		}
		
		if(cont == 0){
			break;
		}
		/*
		if(train[a]==0){
			c++;
		}else{
			b++;
		}
		if(b==c){
		break;
		}
		*/
	}
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	vi input;
	int n;
	while(cin >> n) {
		input.push_back(n);
	}

	stack<int> S;
	REP(i, input.size()) {
		if(input[i]) {
			S.push(input[i]);
		} else {
			cout << S.top() << endl;
			S.pop();
		}
	}

	return 0;
}

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

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

}