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<stdio.h>
#include <stack>

int main(){
	stack<int> st;
	int n, a;

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

C++: #include <stdio.h>

int main() {
	int a,i,k,m;
	int data[15] = {0};
	int output[15] = {0};
	for (i = 0; i < 15; i++) {
		scanf("%d", &a);
		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
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS = 1e-12;
const double INF = 1e12;


int main(){
	int n;
	stack<int>st;
	vector<int>res;
	while(cin>>n){
		if(n!=0)st.push(n);
		else{
			res.PB(st.top());
			st.pop();
		}
	}
	REP(i,SZ(res))cout<<res[i]<<endl;
	return 0;
}

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

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

	while( cin >> carnum )
	{
		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<string>
#include <stdio.h>
#include <math.h>
#include <cctype>
#include<queue>
#include<stack>
using namespace std;
stack<int> st;
int main(){
	int a;
	while(cin>>a){
		if(a!=0){
			st.push(a);
		}
		else{
			cout<<st.top()<<endl;
			st.pop();
		}
	}
	return 0;

}

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

using namespace std;

int main(){
	stack <int> depot;

	int train;

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

	return 0;

}

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

int main() {
	vector<int>v;
	vector<int>::iterator pv=v.begin();
	int n;
	while (cin>>n) {
		if (n == 0) {
			pv = v.end();
			cout << *pv << endl;
			pv = v.begin();
			v.pop_back();
		}
		v.push_back(n);		
	}
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int in;
	vector <int> a;
	while (1) {
		cin >> in;
		if (in == 0) {
			cout << a[a.size() - 1] << endl;
			a.erase(a.end() - 1);
			if (a.size() == 0)
				break;
		}
		else
			a.push_back(in);
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define PUSH intStackPush
#define POP intStackPop
#define TOP intStackTop
#define FREE intStackFree

typedef struct stack{ int data; struct stack* next; }stack;

stack *top = NULL;

stack* makeNewStack(int data){
  stack *new = (stack*)malloc(sizeof(stack));
  new->data = data;
  new->next = NULL;
  return new;
}

void intStackPush(int data){
  stack *new = makeNewStack(data);
  if(top != NULL){ new->next = top; top = new; }
  else top = new;
}

void intStackPop(){
  stack *temp;
  temp = top;
  top = top->next;
  free(temp);
}

int intStackTop(){ return top->data;}

void intStackFree(){ while(top != NULL) intStackPop();}

int main(){
  int in;

  while(scanf("%d", &in) != EOF){
    if(in == 0){
      printf("%d\n",TOP());
      POP();
    }
    else PUSH(in);
  }

  FREE();
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<stack>//?????????????????¢??°

using namespace std;

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

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

int main(void){
	int stack[10];
	int pt=0, n;
	while(cin >> n){
		if(n == 0) {
			cout << stack[pt-1] << endl;
			pt--;
		}
		else {
			stack[pt] = n;
			pt++;
		}
	}
	return 0;
}

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

int main(void){
  stack<int> car;
  int num,res[10000],cnt=0,cnt1=0;

  while( cin >> num ){

    if( num != 0 ) car.push(num);
    else{
      res[cnt] = car.top();
      car.pop();
      cnt++;
      cnt1++;
    }
  }

  cnt = 0;

  while(cnt1){

    cout << res[cnt] << endl; 
    cnt++;
    cnt1--;

  }

  return 0;
}

C++: #include <stdio.h>

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

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <stack>
using namespace std;
int main(){
  int n;
  stack<int> in,out;
  while(cin>>n){
    if(!n)out.push(in.top()),in.pop(),cout<<out.top()<<endl;
    else{in.push(n);}
    if(in.empty()&&!out.empty())return 0;
  }
}

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

int main(void)
{
	int car[20] = {0};
	int in = 0;

	while(car[0] != -1) {
		int n;
		cin >> n;
		car[in] = n;

		if(n == 0) {
			for(int i = in - 1; i >= 0; i--) {
				if(car[i] > 0) {
					cout << car[i] << endl;
					car[i] = -1;
					break;
				}
			}
		}

		in++;
	}
}

C++: #include <iostream>
#include <stack>
using namespace std;
int main(void){
    // Here your code !
    stack<int> s;
   for(int d;cin>>d;){
    
       if(d==0){
           cout<<s.top()<<endl;
           s.pop();}
       else{
           s.push(d);
       }
}
}