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<stdio.h>



int main(){
int N,x;
int A[8]={0,0,0,0,0,0,0};
int n[8]={0,0,0,0,0,0,0};
int n0[8]={0,1,1,1,1,1,1};
int n1[8]={0,0,0,0,1,1,0};
int n2[8]={1,0,1,1,0,1,1};
int n3[8]={1,0,0,1,1,1,1};
int n4[8]={1,1,0,0,1,1,0};
int n5[8]={1,1,0,1,1,0,1};
int n6[8]={1,1,1,1,1,0,1};
int n7[8]={0,1,0,0,1,1,1};
int n8[8]={1,1,1,1,1,1,1};
int n9[8]={1,1,1,1,1,1,1};

while(1){
scanf("%d",&N);if(N==-1)break;
for(int i=0;i<7;i++)
A[i]=0;

for(int i=0;i<N;i++)
{
scanf("%d",&x);
switch(x){

case 0:
for(int i=0;i<7;i++)
n[i]=n0[i];
break;

case 1:
for(int i=0;i<7;i++)
n[i]=n1[i];
break;

case 2:
for(int i=0;i<7;i++)
n[i]=n2[i];
break;

case 3:
for(int i=0;i<7;i++)
n[i]=n3[i];
break;

case 4:
for(int i=0;i<7;i++)
n[i]=n4[i];
break;

case 5:
for(int i=0;i<7;i++)
n[i]=n5[i];
break;

case 6:
for(int i=0;i<7;i++)
n[i]=n6[i];
break;

case 7:
for(int i=0;i<7;i++)
n[i]=n7[i];
break;

case 8:
for(int i=0;i<7;i++)
n[i]=n8[i];
break;

case 9:
for(int i=0;i<7;i++)
n[i]=n9[i];
break;
}
for(int i=0;i<7;i++)
{if(A[i]!=n[i])printf("1");
else if(A[i]==n[i])printf("0");
A[i]=n[i];
}
printf("\n");
}
}
return 0;
}

C++: #include<iostream>

using namespace std;

void setByte(bool *b, int n)
{
  static bool v[11][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},
     {0, 0, 0, 0, 0, 0, 0}};
  for(int i = 0; i < 7; i++)
    b[i] = v[n][i];
}

int main()
{
  bool state[7];
  bool b[7];
  int n;
  while(1)
  {
    setByte(state, 10);
    cin >> n;

    if(n == -1)
      break;

    for(int i = 0; i < n; i++)
    {
      int d;
      cin >> d;
      setByte(b, d);

      for(int j = 0; j < 7; j++)
      {
        state[j] = !(state[j] == b[j]);
        cout << state[j] << (j == 6 ? '\n' : ' ');
      }
      setByte(state, d);
    }
  }
}

C++: #include <iostream>

#define rep(i, n) for(int i = 0; i < n; i ++)

using namespace std;

static const bool PATTERN[11][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,
	0, 0, 0, 0, 0, 0, 0
};

static const int DEFAULT = 10;

int main(void){
	for(int n; cin >> n, n != -1;){
		int preNum = DEFAULT;
		while(n --){
			int num; cin >> num;
			rep(i, 7) cout << (PATTERN[preNum][i] ^ PATTERN[num][i]);
			cout << endl;
			preNum = num; 
		}
	}

	return 0;
}

C++: // 0228.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
int main()
{
	ios::sync_with_stdio(false);
	string a[10];
	a[0] = "0111111";
	a[1] = "0000110";
	a[2] = "1011011";
	a[3] = "1001111";
	a[4] = "1100110";
	a[5] = "1101101";
	a[7] = "0100111";
	a[6] = "1111101";
	a[8] = "1111111";
	a[9] = "1101111";
	while (true) {

		ll n;
		cin >> n;
		if (n == -1) { break; }
		string s = "0000000";
		for (int i = 0; i < n; i++) {
			int d;
			cin >> d;
			for (int j = 0; j < 7; j++) {
				if (a[d][j] == s[j]) { cout << 0; }
				else { cout << 1; }
			}
			cout << endl;
			s = a[d];
		}
	
	}
	
	return 0;
}

C++: #include <cstdio>
#include <stack>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <climits>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	const char* str[] = {
		"0111111",
		"0000110",
		"1011011",
		"1001111",
		"1100110",
		"1101101",
		"1111101",
		"0100111",
		"1111111",
		"1101111"
	};
	int n;
	while(scanf("%d", &n), ~n){
		char s[] = "0000000";
		rep(i, n){
			int a;
			scanf("%d", &a);
			rep(i, 7){
				if(s[i] != str[a][i])
					putchar('1');
				else
					putchar('0');
			}
			puts("");
		}
	}
	return 0;
}

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);
			disp ^= pat[t];
			for (int i = 6; i >= 0; --i)
				printf("%d", (disp >> i) & 1);
			printf("\n");
		}
	}

	return 0;
}

C++: #include <cstdio>

void binarywrite(int n){
	for(int i=6;i>=0;i--){
		printf("%d", (n >> i & 1));
	}
	puts("");
}

int main(){
	long long int lighta = 0x3f065b4f66, lightb = 0x6d7d277f6f;
	int n = 0;
	while(scanf("%d", &n), ~n){
		int prev_j = 0;
		for(int i=n;i;i--){
			int j;
			scanf("%d", &j);
			binarywrite(prev_j ^ (j<5?lighta>>(4-j)*8&0xff:lightb>>(9-j)*8&0xff));
			prev_j = (j<5?lighta>>(4-j)*8&0xff:lightb>>(9-j)*8&0xff);
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	int n;
	map<int,string> d;
	
	d[0]="0111111";
	d[1]="0000110";
	d[2]="1011011";
	d[3]="1001111";
	d[4]="1100110";
	d[5]="1101101";
	d[6]="1111101";
	d[7]="0100111";
	d[8]="1111111";
	d[9]="1101111";
	
	while(cin>>n,n!=-1){
		int a;
		for(int i=0;i<n;i++){
		cin>>a;
		cout<<d[a]<<endl;
		}
	}
}

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

int main(){
	int seg[] = {0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,0b1101101,0b1111101,0b0100111,0b1111111,0b1101111};
	int n;
	while(cin >> n,n != -1){
		int prev = 0;
		for(int i = 0;i < n;i++){
			int t,next;
			cin >> t;
			next = seg[t] ^ prev;
			for(int j = 6;j >= 0;j--){
				cout << (next >> j & 1);
			}
			cout << endl;
			prev = seg[t];
		}
	}
	return 0;
}