Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	n, err := strconv.Atoi(nextString())
	return n, err
}

func main() {
	scanner.Split(bufio.ScanWords)

	stack := []int{}
	for {
		n, err := nextInt()
		if err != nil {
			break
		}

		if n == 0 { // pop
			fmt.Println(stack[len(stack)-1])
			stack = stack[0:(len(stack) - 1)]
		} else { // push
			stack = append(stack, n)
		}
	}
}

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;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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>

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 long long LL;
typedef unsigned long long ULL;

//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
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


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

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

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

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

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	int n, k;
	vector<int> vi, vi2;
	while (cin >> n)
	{
		if (n == 0){
			vi.pop_back();
			vi2.push_back(k);
		}
		else {
			vi.push_back(n);
		}
		k = vi[vi.size() - 1];
	}
	REP(i, vi2.size()){
		cout << vi2[i] << endl;
	}
}

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

int main () {

int a[20]={0}, b[20]={0}, k = 0;
int train = 0, zero = 0;

    for (int i = 0; i < 20; i++){
        cin >> a[i];

    if (a[i] != 0)
        train++;
        else zero++;

    if (train == zero)
        i=100;

    }


    for (int j = 1; j < 20; j++){


            if (a[j-1] != 0 && a[j] == 0){
                b[k] = a[j-1];
                k++;

                for (int count = j; count < 19; count++)
                a[count-1] = a[count+1];

                j = 0;

            }

        }

    for (int n = 0; n < 20; n++) {
        if (b[n] != 0)
        cout << b[n] << endl;

    }

    return 0;

}

C++: #include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int a;
    stack<int> s;
    while(cin >> a){
        if(a)s.push(a);
        else{
            cout << s.top() << endl;
            s.pop();
        }
    }
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int x[1000] ={0},y[1000] = {0};
    int n;
    int a = 0,b = 0;

    while(scanf("%d",&n)!=EOF){
        if(n == 0){
            x[a] = y[b-1];
            b--;
            ++a;
        }
        else {
            y[b] = n;
            b++;
        }
    }
    for(int i = 0;i < a; i++)printf("%d\n",x[i]);

    return 0;
}

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

std::array<u_int, 100> stack;
int point=0;

void push(int p){
	stack[point]=p;
	++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 && point > 0) pop();
		else push(num);
	}

    return 0;
}

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

int main( void )
{
	stack <int> S;
	int first;
	cin >> first;
	S.push( first );

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

	return 0;
}