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<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int A=1, B=2, C=4, D=8, E=16, F=32, G=64;

int sig[10];


int main()
{
    sig[0] =1 + B*1 + C*1 + D*1 + E*1 + F*1 + G*0;
    sig[1] =0 + B*1 + C*1 + D*0 + E*0 + F*0 + G*0;
    sig[2] =1 + B*1 + C*0 + D*1 + E*1 + F*0 + G*1;
    sig[3] =1 + B*1 + C*1 + D*1 + E*0 + F*0 + G*1;
    sig[4] =0 + B*1 + C*1 + D*0 + E*0 + F*1 + G*1;
    sig[5] =1 + B*0 + C*1 + D*1 + E*0 + F*1 + G*1;
    sig[6] =1 + B*0 + C*1 + D*1 + E*1 + F*1 + G*1;
    sig[7] =1 + B*1 + C*1 + D*0 + E*0 + F*1 + G*0;
    sig[8] =1 + B*1 + C*1 + D*1 + E*1 + F*1 + G*1;
    sig[9] =1 + B*1 + C*1 + D*1 + E*0 + F*1 + G*1;

    //REP(10) cout << i << ":" << sig[i] << endl;
    int n;
    while(cin >> n )
    {
        if(n== -1) break;
        int disp = 0, next = 0, ans = 0;
        REP(n)
        {
            cin >> next;
            ans = sig[next]^disp;
            //cout << "ans" << ans << endl;
            rep(j,7)cout << (ans>>(6-j) & 1);
            cout << endl;
            disp = sig[next];
        }
        
    }
    return 0;
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
int bin[7];

void decToBinary(int num) {
    fill(bin, bin+7, 0);
    int i = 6;
    while (num > 0) {
        bin[i] = num % 2;
        num /= 2;
        i--;
    }
    for (i = 0; i < 7; i++) printf("%d", bin[i]);
    printf("\n");
}


int main()
{
    int nums[10] = {63, 6, 91, 79, 102, 109, 125, 39, 127, 111};
    int n, curr, prev, change;
    for (; ;) {
        scanf("%d", &n);
        if (n == -1) break;
        scanf("%d", &prev);
        decToBinary(nums[prev]);
        for (int i = 1; i < n; i++) {
            scanf("%d", &curr);
            change = nums[prev] ^ nums[curr];
            decToBinary(change);
            prev = curr;
        }
    }
    return 0;
}

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

int table[10][7] = {
    {0,1,1,1,1,1,1},//0
    {0,0,0,0,1,1,0},//1
    {1,0,1,1,0,1,1},//2
    {1,0,0,1,1,1,1},//3
    {1,1,0,0,1,1,0},//4
    {1,1,0,1,1,0,1},//5
    {1,1,1,1,1,0,1},//6
    {0,1,0,0,1,1,1},//7
    {1,1,1,1,1,1,1},//8
    {1,1,0,1,1,1,1} //9
};

int main(void){
    // Your code here!
    int n;
    while(true) {
        cin >> n;
        if(n == -1) break;
        
        int k;
        int display[7] = {0,0,0,0,0,0,0};
        for(int i = 0; i < n; i++){
            cin >> k;
            for(int j = 0; j < 7; j++) {
                if(display[j] == table[k][j]) {
                    cout << 0;
                } else {
                    display[j] = table[k][j];
                    cout << 1;
                }
            }
            cout << endl;
        }
    }
}

C++: #include<iostream>
using namespace std;
bool o[15][10] = {};
int main() {
	o[0][1] = true;
	o[0][2] = true;
	o[0][3] = true;
	o[0][4] = true;
	o[0][5] = true;
	o[0][6] = true;
	o[1][4] = true;
	o[1][5] = true;
	o[2][0] = true;
	o[2][2] = true;
	o[2][3] = true;
	o[2][5] = true;
	o[2][6] = true;
	o[3][0] = true;
	o[3][3] = true;
	o[3][4] = true;
	o[3][5] = true;
	o[3][6] = true;
	o[4][0] = true;
	o[4][1] = true;
	o[4][4] = true;
	o[4][5] = true;
	o[5][0] = true;
	o[5][1] = true;
	o[5][3] = true;
	o[5][4] = true;
	o[5][6] = true;
	o[6][0] = true;
	o[6][1] = true;
	o[6][2] = true;
	o[6][3] = true;
	o[6][4] = true;
	o[6][6] = true;
	o[7][1] = true;
	o[7][4] = true;
	o[7][5] = true;
	o[7][6] = true;
	o[8][0] = true;
	o[8][6] = true;
	o[8][1] = true;
	o[8][2] = true;
	o[8][3] = true;
	o[8][4] = true;
	o[8][5] = true;
	o[9][0] = true;
	o[9][1] = true;
	o[9][3] = true;
	o[9][4] = true;
	o[9][5] = true;
	o[9][6] = true;

	int n;
	while (cin >> n) {
		if (n == -1)return 0;
		int k = 10;
		for (int i = 0; i < n; i++) {
			int p; cin >> p;
			for (int i = 0; i < 7; i++)
				cout << (o[k][i] != o[p][i]);
			cout << endl;
			k = p;
		}
	}
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    int s[] = {63,6,91,79,102,109,125,39,127,111};
    while(true){
	int n;
	cin >> n;
	if(n==-1) break;
	int now = 0;
	REP(i,n){
	    int a;
	    cin >> a;
	    now ^= s[a];
	    string ans = "";
	    int temp = now;
	    now = s[a];
	    while(temp>0){
		ans += (char)(temp%2+'0');
		temp/=2;
	    }
	    REP(i,7-ans.size()) cout << "0";
	    RREP(i,ans.size()) cout << ans[i];
	    cout << endl;
	}
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

const int T[][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, 1, 0, 1, 1, 1, 1},
};

int n;
int a[7];

int main()
{
	while (cin >> n, ~n){
		memset(a, 0, sizeof(a));
		rep(i, n){
			int b;
			cin >> b;
			rep(j, 7){
				cout << (a[j] ^ T[b][j]);
				a[j] = T[b][j];
			}
			cout << endl;
		}
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	enum bit
	{
		a = 1,
		b = 1 << 1,
		c = 1 << 2,
		d = 1 << 3,
		e = 1 << 4,
		f = 1 << 5,
		g = 1 << 6,
		all = (1 << 7) - 1,
	};
	const int pat[] = { all^g, b|c, all^c^f, all^e^f, b|c|f|g
		, all^b^e, all^b, a|b|c|f, all, all^e };

	int n, disp, t;
	while (scanf("%d", &n), n != -1)
	{
		disp = 0;
		while (n--)
		{
			scanf("%d", &t);
			for (int i = 6; i >= 0; --i)
				printf("%d", ((disp ^ pat[t]) >> i) & 1);
			printf("\n");
			disp = pat[t];
		}
	}

	return 0;
}