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 <bits/stdc++.h>
using namespace std;

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

int main() {

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

  return 0;
}

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

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

	while( !car.empty() || outlist.empty() )
	{
		int carnum;
		cin >> carnum;
		if(carnum)
		{
			car.push(carnum);
		}
		else
		{
			outlist.push_back(car.top());
			car.pop();
		}
	}
	
	cout << '\n';
	for(size_t i=0; i<outlist.size(); ++i)
	{
		cout << outlist[i] << '\n';
	}
}

C++: #include <cstdio>

using namespace std;

int main()
{
	int in[10];
	int i = 0;

	while (scanf("%d", &in[i])){
		if (in[i] == 0){
			i--;
			printf("%d\n", in[i]);
		}
		else {
			i++;
		}
	}
}

C++: #include<iostream>
using namespace std;
int main(){
	int now=-1;
	int n[10]={0};
	int in;
		while(cin>>in){
		if(in==0){
			cout<<n[now];
			now--;
			if(now==-1)return 0;
		}
		else{
			n[now+1]=in;
			now++;
		}
	}
}

C++: #include　<iostream>

int stack[100];
int point=0;

void push(int p){
	stack[point]=0;
	++point;
}

void pop(){
	std::cout << stack[point] << std::endl;
	--point;
}

int main(){
	int num;

	for(int i=0;i<100;i++){
		std::cin >> num;
		if(num==0) pop();
		else push(num);
	}

    return 0;
}

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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

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

C++: #include<iostream>

using namespace std;

int main(){

int aaa[200];
int ii=0;

while(cin>>aaa[ii]){
ii++;
}

for(int i=0;i<ii;i++){
if(aaa[i]==0){
for(int j=i-1;;j--){
if(aaa[j]!=0){
cout<<aaa[j]<<endl;
aaa[j]=0;
break;
}
}
}
}


}

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

int size(){
 return sp;
}

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){
   pop();
  }
  top();
  printf("%d\n", top());
 }
}

C++:     #include <iostream>
    using namespace std;
     
    int a[11], b, t;
     
    int main() {
      cin>>a[0];
      t=1;
      c=0;
     
      while(cin>>b) {
        if(b>0) {
          a[t]=b;
          t++;
        }else {
          cout<<a[t-1]<<endl;
          t--;
        }
      }
      
      return 0;
    }

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

struct stack{
	int element;
	struct stack *next;
};
int top(struct stack *s){
	return s->element;
}
struct stack* pop(struct stack *s){
	struct stack *p, *q;
	q = s;
	p = s->next;
	free(q);
	s = p;
	return s;
}
struct stack* push(struct stack *s, int x){
	struct stack *p, *q;
	q = s;
	p = (struct stack*)malloc(sizeof(struct stack));
	p->element = x;
	p->next = q;
	s = p;
	return s;
}

int main(){
	struct stack *S=NULL;
	int num;
	while (1){
		cin>>num;
		if (num==0){
			cout<<top(S)<<endl;
			S = pop(S);
		} else{
			S=push(S, num);
		}
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main() {
	int a;
	vector<int> s;
	while (cin >> a) {
		if (a != 0) {
			s.push_back(a);
		}
		else if (a == 0) {
			cout << s[s.size() - 1] << endl;
			s.pop_back();
		}
	}
	return 0;
}

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

using namespace std;

int main(){

  int train;
  stack<int> s;

  cin >> train;

  s.push(train);

  while(!s.empty()){

    cin >> train;

    if(train) s.push(train);
    else {
      cout << s.top() << endl;
      s.pop();
    }

  }

}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

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

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <iomanip>
using namespace std;
int main(){
  int in[10]={0},out[10]={0},i=0,o=0,n;
  while(cin>>n){
    if(!n)out[o++]=in[--i],in[i]=0,cout<<out[o-1]<<endl;
    else{in[i++]=n;}
    if(!i&&o>0)return 0;
  }
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


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

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

using namespace std;

int main() {
	string str, str2, ans;
	int i, j, l, n = 0;
	while (cin >> str) {
		ans += str;
		ans += ' ';
		if (n != 0) {
			continue;
		}
		l = str.length();
		str2.resize(l);
		for (i = 1; i < 26; i++) {
			for (j = 0; j < l; j++) {
				if (str[j] == '.') {
					continue;
				}
				if (str[j] + i > 'z') {
					str2[j] = str[j] - 26 + i;
				}
				else {
					str2[j] = str[j] + i;
				}
			}
			if (str2 == "the" || str2 == "the." || str2 == "this" || str2 == "this." || str2 == "that" || str2 == "that.") {
				n = i;
				break;
			}
		}
	}
	l = ans.length();
	ans.erase(l - 1);
	for (i = 0; i < l; i++) {
		if (ans[i] == '.' || ans[i] == ' ') {
			continue;
		}
		if (ans[i] + n > 'z') {
			ans[i] = ans[i] - 26 + n;
		}
		else {
			ans[i] = ans[i] + n;
		}
	}
	cout << ans << endl;
	return 0;
}