Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	table := [][]int{ // abcdefgの順番の
	{1,1,1,1,1,1,0}, // 1
	{0,1,1,0,0,0,0}, // 2
	{1,1,0,1,1,0,1}, // 3
	{1,1,1,1,0,0,1}, // 4
	{0,1,1,0,0,1,1}, // 5
	{1,0,1,1,0,1,1}, // 6
	{1,0,1,1,1,1,1}, // 7
	{1,1,1,0,0,1,0}, // 8
	{1,1,1,1,1,1,1}, // 9
	{1,1,1,1,0,1,1}, // 10
	}
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == -1 {
			break
		}
		initial := []int{0,0,0,0,0,0,0}
		for i := 0; i < n; i++ {
			scanner.Scan()
			d, _ := strconv.Atoi(scanner.Text())
			for j := 6; j >= 0; j-- {
				fmt.Printf("%d", initial[j]^table[d][j])
				initial[j] = table[d][j]
			}
			fmt.Println()
		}
	}
}

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

int main(){
  vector<string> seg;
  int n, s, count=0, ago;

    seg.push_back("0111111"); // 0
    seg.push_back("0000110"); // 1
    seg.push_back("1011011"); // 2
    seg.push_back("1001111"); // 3
    seg.push_back("1100110"); // 4 
    seg.push_back("1101101"); // 5 
    seg.push_back("1111101"); // 6 
    seg.push_back("0111111"); // 7
    seg.push_back("1111111"); // 8
    seg.push_back("1101111"); // 9


  while(cin >> n){
    if(n < 0) return 0;
    string start,result,ans="0000000";
    for(int i=0; i<n; i++){
      cin >> s;
      if(count == 0){
	start = seg[s];
	cout << start << endl;
	count++;
	ago = s;
	continue;
      }
      start = seg[ago];
      result = seg[s];

      for(int j=0; j<7; j++){
	if(start[j] == result[j]) ans[j] = '0';
	else ans[j] = '1';
      }
      cout <<  ans << endl;

      ago = s;
    }
    count=0;
  }
}

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

int main(){
  vector<string> seg;
  int n, s;

    seg.push_back("0111111"); // 0
    seg.push_back("0000110"); // 1
    seg.push_back("1011011"); // 2
    seg.push_back("1001111"); // 3
    seg.push_back("1100110"); // 4 
    seg.push_back("1101101"); // 5 
    seg.push_back("1111101"); // 6 
    seg.push_back("0111111"); // 7
    seg.push_back("1111111"); // 8
    seg.push_back("1101111"); // 9


  while(cin >> n){
    if(n < 0) return 0;
    string start="0000000",result,ans="0000000";
    for(int i=0; i<n; i++){
      cin >> s;
      result = seg[s];
      for(int j=0; j<7; j++){
	if(start[j] == result[j]) ans[j] = '0';
	else ans[j] = '1';
      }
      cout <<  ans << endl;
      start = seg[s];
    }
  }
}

C++: # define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }


int main()
{
	while (true)
	{
		string dat[] = { "0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "11111111", "1101111" };
		INT(n);
		if (n == -1)break;
		string now = "0000000";
		FOR(i, n)
		{
			INT(x);
			FOR(j, 7)
			{
				if (now[j] != dat[x][j])cout << 1;
				else cout << 0;
			}
			cout << endl;
			now = dat[x];
		}
	}
}

C++: #include<iostream>
#include<complex>
using namespace std;int main(){int m[10][7];for(int i=0;i<10;i++)for(int j=0;j<7;j++)m[i][j]=1;m[0][6]=0,m[1][0]=0,m[1][3]=0,m[1][4]=0,m[1][5]=0,m[1][6]=0,m[2][2]=0,m[2][5]=0,m[3][4]=0,m[3][5]=0,m[4][0]=0,m[4][3]=0,m[4][4]=0,m[5][1]=0,m[5][4]=0,m[6][1]=0,m[7][3]=0,m[7][4]=0,m[7][6]=0,m[9][4]=0;int n,a,set;while(true){cin>>n;if(n==-1)break;cin>>set;for(int i=6;i>=0;i--)cout<<m[set][i];cout<<endl;for(int i=1;i<n;i++){cin>>a;for(int i=6;i>=0;i--)cout<<abs(m[set][i]-m[a][i]);cout<<endl;set=a;}}return 0;}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    vector<int> seg = {0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,0b1101101,0b1111101,0b0100111,0b1111111,0b1101111};
    int n;cin >> n;
    while(n!=-1){
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    rep(i,n){
        if(i!=0){
            cout << bitset<7>(seg[v[i]]^seg[v[i-1]]) << endl;
        }else{
            cout << bitset<7>(seg[v[0]]) << endl;
        }
    }
    cin >> n;
    }
}

C++: // 2011/02/18 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int seg[11][7] = {{0,1,1,1,1,1,1},		// eÌf[^
	                  {0,0,0,0,1,1,0},
	                  {1,0,1,1,0,1,1},
	                  {1,0,0,1,1,1,1},
	                  {1,1,0,0,1,1,0},
	                  {1,1,0,1,1,0,1},
	                  {1,1,1,1,1,0,1},
	                  {0,1,0,0,1,1,1},
	                  {1,1,1,1,1,1,1},
	                  {1,1,0,1,1,1,1},
	                  {0,0,0,0,0,0,0}};		// seg[10]ÍúóÔ

	while(true){
		int n;
		cin >> n;
		if(n==-1)
			break;

		int pst = 10;		// 1ÂOÌiúlÍñ\¦j
		int now;		// »ÝÌ
		for(int i=0; i<n; i++){
			cin >> now;
			for(int j=0; j<7; j++)
				cout << (seg[pst][j]+seg[now][j])%2;		// ¯¶Èç0CÙÈéÈç1
			cout << endl;
			pst = now;
		}
	}

	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	int seg[]{
		0b0111111,
		0b0000110,
		0b1011011,
		0b1001111,
		0b1100110,
		0b1101101,
		0b1111101,
		0b0100111,
		0b1111111,
		0b1101111
	};
	int n;
	while (cin >> n, ~n) {
		int now = 0;
		rep(i, n) {
			int j; cin >> j;
			cout << bitset<7>(seg[j] ^ now) << endl;
			now = seg[j];
		}
	}
}