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>
using namespace std;
int main() {
	string date[11],now;
	date[0] = "1111110";
	date[1] = "0110000";
	date[2] = "0110000";
	date[3] = "1111001";
	date[4] = "0110011";
	date[5] = "1011011";
	date[6] = "1011111";
	date[7] = "1110010";
	date[8] = "1111111";
	date[9] = "1111011";
	int n,kazu[111];
	while (1) {
		now = "0000000";
		cin >> n;
		if (n == -1) goto a;
		for (int i = 1; i <= n; i++) {
			cin >> kazu[i];
		}
		for (int i = 1; i <= n; i++) {
			for(int z=6;z>=0;z--){
				if (date[kazu[i]][z] == now[z]) {
					cout << 0;
				}
				else {
					cout << 1;
					if (now[z] == '0') {
						now[z] = '1';
					}
					else {
						now[z] = '0';
					}
				}
			}
			cout << endl;
		}
	}
a:;
}

C++: #include <iostream>
using namespace std;
int main (){
  bool d[10][7] ={{0,1,1,1,1,1,1},
                 {0,0,0,1,1,0,0},
                 {1,1,1,0,1,1,0},
                 {1,0,1,1,1,1,0},
                 {1,0,0,1,1,0,1},
                 {1,0,1,1,0,1,1},
		 {1,1,1,1,0,1,1},
		 {0,0,0,1,1,1,1},
		 {1,1,1,1,1,1,1},
		 {1,0,1,1,1,1,1}};

  int n;
  while(cin>>n && n!=-1){
    bool s[7] = {0,0,0,0,0,0,0};
    for(int i=0;i<n;i++){
      int a;
      cin >>a;
      for(int j=0;j<7;j++){
	if(s[i]!=d[a][j]){
	  cout<<1;
	  s[i]=d[a][i];
	}
	else cout <<0;
      }
      cout <<endl;
    }
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  unsigned long num[11]={63,6,91,79,102,109,125,39,127,111,0};
  int n,a,b=10;
  while(cin>>n,n!=-1){
    bitset<7> now((unsigned long)0);
    b=10;
    for(int i=0;i<n;i++){
      cin>>a;
      now=num[b]^num[a];
      for(int i=6;i>=0;i--){
	cout<<now[i];
      }
      cout<<endl;
      b=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" };
	string state = "0000000";
	for (int n; cin >> n&&n != -1;) {
		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>
using namespace std;

string s[10] = {
	"0111111",
	"0000110",
	"1011011",
	"1001111",
	"1100110",
	"1101101",
	"1111101",
	"0100111",
	"1111111",
	"1101111",
};


int main(void){
	int n;
	while(cin>>n, (n!=-1)){
		string now = "0000000";
		for(int i=0;i<n;i++){
			int x;
			cin>>x;
			string change = "0000000";
			for(int i=0;i<7;i++){
				if(s[x][i] != now[i]){
					change[i] = '1';
				}
			}
			cout<<change<<endl;
			now = s[x];
		}
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	string table[] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
	int n;
	while(cin >> n , ~n){
		string cur = "0000000";
		rep(i,n){
			int number; cin >> number;
			rep(i,7)cout << (cur[i] != table[number][i]);
			cout << endl;
			cur = table[number];
		}
	}
}

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

int main()
{
	int a, b, i;
	string n, d[10] = { "0111111" , "0000110" , "1011011" , "1001111" , "1100110" , "1101101" , "1111101" , "0100111" , "1111111" , "1101111" };
	while (cin >> a)
	{
		if (a == -1)break;
		n = "0000000";
		for (i = 0; i < a; i++)
		{
			cin >> b;
			for (int j = 0; j < 7; j++)
			{
				if (n[j] == d[b][j])
				{
					cout << "0";
				}
				else
				{
					cout << "1";
				}
			}
			n = d[b];
			cout << endl;
		}
	}
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cctype>
#include <sstream>
#include <algorithm>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for (iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define pr(a) cout << (a) << endl
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000000;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  string s[10];
  s[0]="0111111";
  s[1]="0000110";
  s[2]="1011011";
  s[3]="1001111";
  s[4]="1100110";
  s[5]="1101101";
  s[6]="1111101";
  s[7]="0100111";
  s[8]="1111111";
  s[9]="1101111";
  
  int n;
  while(cin >> n && n!=-1) {
    string t="0000000";
    rep(j,n) {
      int x;
      cin >> x;
      rep(i,7) cout << !(t[i]==s[x][i]);
      cout << endl;
      t=s[x];
    }
  }
  return 0;
}

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

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

    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;
    
    for(int i=0; i<n; i++){
      cin >> s;
      if(count == 0){
	cout << seg[s] << endl;
	count++;
	ago = s;
	continue;
      }
	a = seg[ago];
	b = seg[s];
      for(int j=0; j<7; j++){
	if(a[j] == b[j]) cout << '0';
	else cout << '1';
      }
      cout << endl;

      ago = s;
    }
    count=0;
  }
}

C++: #include<iostream>
using namespace std;
int main(){

    bool data[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 n;
    while(cin>>n,n!=-1){
        bool now[7]={0,0,0,0,0,0,0};
        for(int i=0;i<n;i++){
            int x;
            cin>>x;

            for(int i=6;i>=0;i--){
                if(now[i]!=data[x][i]){
                    now[i]=1-now[i];
                    cout<<1;
                }
                else cout<<0;
            }
            cout<<endl;
        }
    }
    return 0;
}