Go: package main

import "fmt"

func main() {
	stack := []int{}
	for {
		var a int
		i, _ := fmt.Scan(&a)
		if i == 0 {
			break
		}
		if a == 0 {
			fmt.Println(stack[len(stack)-1])
			stack = stack[:len(stack)-1]
			continue
		}
		stack = append(stack, a)
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<cfloat>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P; /* ツ点 */

#define PI (3.1415926535)
#define EPS (1e-10)

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

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

int main(void) {
    stack<int> unforwardable;
    vector<int> output;
    int car;
    while(cin >> car) {
        if(car == 0) {
            output.push_back(unforwardable.top());
            unforwardable.pop();
        } else {
            unforwardable.push(car);
        }
    }
    vector<int>::iterator ite;
    for(ite = output.begin(); ite != output.end(); ite++) {
        cout << *ite << endl;
    }
    return(0);
}

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

int main(void){
    vector<int> v;
    int n;
    while(cin>>n){
        if(n==0){
            cout<<v.back()<<endl;
            v.pop_back();
        }
        else{
            v.push_back(n);
        }
    }
    return 0;
}

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

using namespace std;

int main(){
	string code;
	string train;
	int i,j;

	while(cin >> code){
		if(code == "10") code = 'A';

		if(code == "0"){
			if(train[train.size()-1] == 'A'){
				cout << "10" << endl;
			}else{
				cout << train[train.size()-1] << endl;
			}
			string temp;
			for(i=0 ; i<train.size()-1 ; i++){
				temp += train[i];
			}
			train = temp;
		}else{
			train += code;
		}
	}

}

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

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

C++: #include<iostream>
#include<vector>
using namespace std;
int main() {
	vector<int> line;
	int code;
	while (1) {
		cin >> code;
		if (code != 0) {
			line.push_back(code);
		}
		else {
			cout << *(line.end() - 1) << endl;
			line.pop_back();
		}
	}
	return 0;
}

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

int main ()
{
    std::stack<u_int> cars;
    u_int number;

    while(std::cin >> number){
        if(number != 0)
            cars.push(number);
        else{
            std::cout << cars.top() << std::endl;
            cars.pop();
        }
    }
    
    return 0;
}

C++: #include <cstdio>
#include <stack>
#define FOR(variable,a,b) for(variable=(a);variable<(b);variable++)

using namespace std;

int main() {
    // import phase
    int target;
    stack<int> map;
    
    // calculate phase
    while(scanf("%d", &target) != EOF) {
        if(target != 0) {
            map.push(target);
        } else {
            printf("%d\n", map.top());
            map.pop();
        }
    }

    return 0;
}

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

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

C++: #include<stdio.h>
int main(){
  int n,m,i=0,j=0,h=0;
  int data[20];
  int str[10];
  while(scanf("%d",&n)!=EOF){
    data[i]=n;
    if(n==0){
      j=i;
      while(data[i-1]==0){
	i--;
      }
      str[h]=data[i-1];
      data[i-1]=0;
      i=j;
      j=0;
      h++;
    }
    i++;
  }
  for(i=0;i<h;i++){
    printf("%d\n",str[i]);
  }
  return(0);
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<math.h>
using namespace std;

int main()
{
	
	vector<int>a;
	vector<int>b;
	vector<int>c;
	int s[20];
while(true)
{
for(int i=0;i<20;i++)
{
	cin>>s[i];

if(s[i]==0)
	{
		b.push_back(s[i]);
		a.push_back(c.back());
		c.pop_back();
		if(c.size()==0)
		{
		break;
		}
	}
	else
	{
		c.push_back(s[i]);
	}
	
}
for(int j=0;j<a.size();j++)cout<<a[j]<<endl;
	}
return 0;
}

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

int main(void) {

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

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


int main(){

  int train[20] , num[20];

 for( int i = 0; i < 20; i++ ){
    train[i] = 0;
    num[i] = 0;
 }

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

    cin >> train[i];

    if( train[i] == 0 ){
      for( int j = i; j >= 0; j-- ){
	if( train[j] != 0 ){
	num[i] = train[j];
	train[j] = 0;
	break;
	}
      }
    }
  }
  
  cout << endl;
  for( int k = 0; k < 20; k++ ){
    if( num[k] != 0 ) cout  << num[k] << endl; 

  }


  return 0;
}

C++: /*AOJ 0013*/

#include<iostream>
#include<stack>
#include<queue>

using namespace std;

int main(){

	stack<int> data;
	queue<int> ans;

	int tmp;

	cin>>tmp;

	data.push(tmp);

	int flag = 0;
	for(;;){

		flag = 0;

		cin>>tmp;

		if(tmp == 0){
			ans.push(data.top());
			data.pop();
			if(data.size()==0){
				flag = 1;
			}
		}
		else{
			data.push(tmp);
		}

		if(flag == 1){
			break;
		}
	}
	while(ans.size()!=0){
		cout<<ans.front()<<endl;
		ans.pop();
	}

	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<memory>
#include<array>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>

using namespace std;

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

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

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	vector<int> a(100);
	int b;
	int i=0;
	while(cin>>b){
		if(b!=0){
			a[i]=b;
			i++;
		}
		else if(b==0){
			cout<<a.at(i-1)<<endl;
			a.erase(a.begin()+i-1);
			i--;
		}
	}
	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==0){
      printf("%d\n",top());
      pop();
    }else{
      push(n);
    }
    if(n==EOF)break;
  }
  return 0;
}

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

using namespace std;

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