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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

std::string to_binString(unsigned int val)
{
  std::string str = "";
  while( val != 0 ) {
    if( (val & 1) == 0 )
      str.insert(str.begin(), '0');
    else
      str.insert(str.begin(), '1');
    val >>= 1;
  }
  while(str.size()<7){
    str = "0" + str;
  }
  return str;
}

const int bit[10] = {126,48,109,121,51,91,95,114,127,123};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
//   rep(i,10){
//     cout << i << " " +to_binString(bit[i])<<endl;
//   }
  ll n;
  while(cin >> n && n != -1){
    ll a;
    int state = 0;
    rep(i,n){
      cin >> a;
      auto s = to_binString(state ^ bit[a]);
      reverse(all(s));
      cout << s <<endl;
      state = bit[a];
    }
  }
  return 0;
}

C++: #include <iostream>
#include <cstring>
using namespace std;
int main()
{
	char s[10][8] = {"0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111"};
	int n, a, i, j;
	while (cin >> n)
	{
		if (n < 0) break;
		char t[8] = "0000000";
		for (i = 0; i < n; i++)
		{
			cin >> a;
			for (j = 0; j < 8; j++)
			{
				if (t[j] == s[a][j])	t[j] = '0';
				else					t[j] = '1';
			}
			t[7] = '\0';
			cout << t << endl;
			strcpy(t, s[a]);
		}
	}
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	string s[] = { 
		"0111111",
		"0000110",
		"1011011",
		"1001111",
		"1100110",
		"1101101",
		"1111101",
		"0100111",
		"1111111",
		"1101111" 
	};
	for (int n; cin >> n&&n != -1;) {
		string state = "0000000";
		rep(i, 0, n) {
			int a; cin >> a;
			string ans = "";
			rep(i, 0, 7) {
				if (s[a][i] == state[i])ans += "0";
				else ans += "1";
			}
			cout << ans << endl;
			state = s[a];
		}
	}
	return 0;
}

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

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define REP(i,b,n) for(i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))

using namespace std;

int n;
char seg[11][8] = { "1111110", "0110000", "1101101", "1111001", "0110011", 
					"1011011", "1011111", "1110010", "1111111", "1111011", "0000000"};
					
string solve(int a, int b)
{	
	string res = "";
	
	FOR(i, 0, 7)
	{
		if( seg[a][i] == seg[b][i] )
			res += '0';
		else
			res += '1';
	}
	
	return string(res.rbegin(), res.rend());
}

int main()
{
	while(cin >> n, n != -1)
	{
		int a = 10;
		
		FOR(i, 0, n)
		{
			int b;
			cin >> b;
			cout << solve(a, b) << endl;
			a = b;
		}
		
	}
	
	return 0;
}

C++: b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);}

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

using namespace std;

int main()
{
  int n, c;
  const int num[10][7] = {
    0, 1, 1, 1, 1, 1, 1,
    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, 0,
    0, 1, 0, 0, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1,
    1, 1, 0, 1, 1, 1, 1
  };

  while (cin >> n, n != -1){
    int seg[] = {0, 0, 0, 0, 0, 0, 0};
    while (n--){
      cin >> c;
      for (int i = 0; i < 7; i++){
        if (seg[i] != num[c][i]){
          seg[i] = 1;
        }
        else {
          seg[i] = 0;
        }
        cout << seg[i];
      }
      memcpy(seg, num[c], sizeof(int) * 7);
      cout << endl;
    }
  }

  return (0);
}

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

int main(){
  int N;
  int prev[7];
  char temp[10][8] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
  while(cin >> N,N>=0){
    fill(prev,prev+7,0);
    while(N--){
      int ans[7],n,fig[7];
      cin >> n;
      for(int i=0;i<7;i++){
	if(temp[n][i] -'0' != prev[i]) ans[i] = 1;
	else ans[i] = 0;
      }
      for(int i=0;i<7;i++) fig[i] = temp[n][i]-'0';
      for(int i=0;i<7;i++) cout << ans[i];
      cout << endl;
      copy(fig,fig+7,prev);
    }
  }
}

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

using namespace std;

int ss[10][7] = {
  { 0, 1, 1, 1, 1, 1, 1 },
  { 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, 0, 1, 1, 1, 1, 1 }
};

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == -1) return 0;
    int d[7];
    fill(d, d+7, 0);
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      for (int j = 0; j < 7; j++) {
        cout << (d[j] ^ ss[x][j]);
        d[j] = ss[x][j];
      }
      cout << endl;
    }
  }
}