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 <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

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

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

using namespace std;



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

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

int main(){
    int cnt = 0;
    int sta;
    int train[10]={0};
    while(cin >> sta){
        if(sta == 0){
            cnt--;
            cout << train[cnt] << endl;
        }
        else {
            train[cnt] = sta;
            cnt++;
        }
    }
}

C++: #include <stdio.h>
const int SIZE = 100;
int data[SIZE];
int sp= 0;


int top(){
 return data[sp-1];
}
void pop(){
 sp--;
}

void push(int v){
 data[sp] = v;
 sp++;
}

int main(){
 int v;
 while(scanf("%d", &v) != EOF){
  if(v != 0){
   push(v);
  }
  if(v == 0){
   printf("%d\n", top());
   pop();
  }
 }
 return 0;
}

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

using namespace std;
int main(){
  int op;
  stack<int> intStack;
  while(cin>> op){
    if(op == 0){
      cout << intStack.top() << endl;
      intStack.pop();
    } else {
      intStack.push(op);
    }
  }
  return 0;
}

C++: #include <stdio.h>
#include <stack>
 
int main(void) {
  std::stack<int> st;
  int n;
  while(scanf("%d", &n) != EOF) {
    if(n) st.push(n);
    else {
      printf("%d\n", st.top());
      st.pop();
    }
  }
  return 0;
}

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

int main(){
	int track[100];
	int x;
	int counter=0;
	int exit[100];
	int exit_number=0;
	while(cin >> x){
		if(x==0){
			counter--;
			exit[exit_number]=track[counter];
			exit_number++;
			
		}
		else{
			track[counter]=x;
			counter++;
		}
	}
	for(x=0; x<exit_number;x++){
		cout << exit[x] << endl;
	}
}

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

C++: #include <cstdio>
#include <stack>
using namespace std;
  int main(){
   int train[11],n;
   stack<int> s;
   while(scanf("%d",&n) != EOF){
      if(n != 0){
        s.push(n);
           }else{
             printf("%d\n",s.top());
			 s.pop();
         }
}
return 0;
}

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

int main(){
  stack<int> S;

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

C++: #include<iostream>

using namespace std;

int main() {
	int train[20] = { 0 }, junban[20] = { 0 }, a = 0, n, i;	
	while (cin >> n) {
		if (n == 0) {
			for (i = 0; train[i] != 0; i++) {}
			junban[a] = train[i - 1];
			train[i - 1] = 0;
			a++;
		}
		else {
			for (i = 0; train[i] != 0; i++) {}
			train[i] = n;
		}
	}
	for (i = 0; junban[i] > 0; i++) {
		cout << junban[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <stack>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

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 <stack>
using namespace std;

int main(){

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


  }


  return 0;

}

C++: #include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int a[25]={1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int b,c;

int main()
{
	b=0;
	while(a[0]!=0)
	{
		scanf("%d",&a[b]);
		if(a[b]==0)
		{
			for(c=24;c>=0;c--)
			{
				if(a[c]!=0)
				{
					printf("%d\n",a[c]);
					a[c]=0;
					break;
				}
			}
		}
		b++;
	}
	return 0;
}

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

using namespace std;


int main()
{
	int n[11],count=0,m;
	while(scanf("%d",&m)!=EOF){
		
		if(m==0){
			count--;
			cout<<n[count]<<endl;		
		}
		else{
			n[count]=m;
			count++;
		}
	}

	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 <algorithm>
#include <string>
#include <stack>
using namespace std;
int main(void) {
	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>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]){
    int input; 
    int input_order[100];
    stack<int> train_stack;
    vector<int> order;

    while (~scanf("%d", &input)){
        if (input==0){
            cout<<train_stack.top()<<endl;
            train_stack.pop();
        }
        else{
            train_stack.push(input);
        }
    }
    return 0;
}

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

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

int main()
{
	int car[10],order[100],i,j,k=0;
	
	for(i=0; i<10; i++){car[i]=0;}
	i=0;
	while((scanf("%d",&order[i]))!=EOF){i++;}
	for(j=0; j<i; j++){
		if(order[j]!=0){
			car[k]=order[j];
			k++;
		}else{
			k--;
			cout << car[k] << endl;
			car[k]=0;
		}
	}
}

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

int main(){
stack<int>a;
int b;
while(scanf("%d",&b)){
	if(b)a.push(b);
	else {printf("%d\n",a.top());a.pop();}
}
}

C++: #include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
	int N;
	stack<int> st;
	while( cin >> N )
	{
		if( N == 0 ){
			cout << st.top() << endl;
			st.pop();
			continue;
		}
		st.emplace( N );
	}
	return 0;
}

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

using namespace std;

int main() {

	int n;
	stack<int> line;

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

	return 0;
}

C++: #include<stdio.h>
int i=0,j=0;
int cars[19];

int main(){
    while(1)
    {

        if(scanf("%d",&cars[i])==-1)
        {
            break;
        }
        if(cars[i]==0){
            printf("%d\n",cars[i-1]);
            i--;
            j++;
        }
        else
        {
            i++;
        }
        if(j==10)
        {
            break;
        }
    }
    return 0;
}

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

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