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()
		}
	}
}

Python: ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n==-1:
		break
	e=0
	for i in range(n):
		a=ref[int(raw_input())]
		print ("{:07b}".format(a^e))
		e=a

Python: ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n+1==0:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

Python: # AOJ 0228: Seven Segments
# Python3 2018.6.25 bal4u

p = [[1,1,1,1,1,1,0], [0,1,1,0,0,0,0], [1,1,0,1,1,0,1], [1,1,1,1,0,0,1], [0,1,1,0,0,1,1], \
     [1,0,1,1,0,1,1], [1,0,1,1,1,1,1], [1,1,1,0,0,1,0], [1,1,1,1,1,1,1], [1,1,1,1,0,1,1]]

while True:
	n = int(input())
	if n < 0: break
	a = [0]*7
	for i in range(n):
		d = int(input())
		ans = ''
		for j in range(6,-1,-1):
			k = (a[j] ^ p[d][j]) & 1
			ans += '1' if k else '0'
			if k: a[j] = 1-a[j]
		print(ans)

Python: ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

Python: ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n==-1:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

Python: ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n==10:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

C++: #include <iostream>

using namespace std;

int main() {
    int n, k;
    char out[10][8] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
    while (cin >> n, n != -1) {
          for (int i = 0; i < n; ++i) {
              cin >> k;
              cout << out[k] << endl;
          }
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> Pair;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

vector<int> seg = {0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110,
                   0b1101101, 0b1111101, 0b0100111, 0b1111111, 0b1101111};

int main() {
    while(true) {
        ll n = IN();
        if(n == -1) return 0;
        int pre = 0;
        REP(i, n) {
            int d = IN();
            cout << bitset<7>(seg[d] ^ pre) << "\n";
            pre = seg[d];
        }
    }
}

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 && n > 100) return 0;
    string start="0000000",ans="0000000";
    for(int i=0; i<n; i++){
      cin >> s;
      string result = seg[s];

       cout << "start:  " << start << endl;
       cout << "result: " << result << endl;

      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];
    }
  }
  return 0;
}

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

int main() {
    string binary[10];
    binary[0] = "0111111";
    binary[1] = "0000110";
    binary[2] = "1011011";
    binary[3] = "1001111";
    binary[4] = "1100110";
    binary[5] = "1101101";
    binary[6] = "1111101";
    binary[7] = "0100111";
    binary[8] = "1111111";
    binary[9] = "1101111";
    
    while (true) {
        int n;
        cin >> n;
        
        if (n==-1) {
            break;
        }
        
        string now = "0000000";
        
        for (int i=0; i<n; i++) {
            int d;
            cin >> d;
            string res = "";
            
            for (int i=0; i<7; i++) {
                if (now[i]==binary[d][i]) {
                    res += "0";
                }
                else {
                    res += "1";
                }
            }
            
            now = binary[d];
            
            cout << res << endl;
        }
    }
}

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

int main() {
  const string list[10] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
  int M[10] = {};
  for(int i=0; i<10; i++)
    for(int j=0; j<7; j++)
      M[i] += (list[i][j]-'0') << j;
  
  int N;
  while(cin >> N && (N!=-1)) {
    int S = 0;
    for(int i=0; i<N; i++) {
      int x; cin >> x;
      S ^= M[x];
      for(int j=0; j<7; j++) {
        cout << (S >> j & 1);
      }
      S = M[x];
      cout << endl;
    }
  }
  return 0;
}

C++: #include <cstdio>

int tab[10][7]={
    {1,1,1,1,1,1,0},
    {0,1,1,0,0,0,0},
    {1,1,0,1,1,0,1},
    {1,1,1,1,0,0,1},
    {0,1,1,0,0,1,1},
    {1,0,1,1,0,1,1},
    {1,0,1,1,1,1,1},
    {1,1,1,0,0,1,0},
    {1,1,1,1,1,1,1},
    {1,1,1,1,0,1,1}
};
int main(){
    int n;
    for(;;){
        scanf("%d",&n);
        if(n==-1) break;
        int now[7];
        for(int i=0;i<7;i++){
            now[i]=0;
        }
        int m;
        for(int i=0;i<n;i++){
            scanf("%d",&m);
            for(int j=6;j>=0;j--){
                printf("%d",now[j]^tab[m][j]);
                now[j]=tab[m][j];
            }
            printf("\n");
        }
    }
}