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 signal(int *da,int set){
	if(set==1){
		if(*da==0){
			*da=1;
			return 1;
		}
		else{
			*da=1;
			return 0;
		}
	}
	else {
		if(*da==0){
			*da=0;
			return 0;
		}
		else{
			*da=0;
			return 1;
		}
	}
}

class seg{
public:
	int a,b,c,d,e,f,g;
	int da,db,dc,dd,de,df,dg;
	void empty();
	void set(int num);
	void Set(int num);
};
void seg::empty(){
  /*switch(num){
  case 0:
	  a=b=c=d=e=f=1;
	  g=0;
	  break;
  case 1:
	  b=c=1;
	  a=d=e=f=g=0;
	  break;
  case 2:
	  a=b=d=e=g=1;
	  c=f=0;
	  break;
  case 3:
	  a=b=c=d=g=1;
	  f=e=0;
	  break;
  case 4:
	  b=c=f=g=1;
	  a=e=d=0;
	  break;
  case 5:
	  a=c=d=f=g=1;
	  b=e=0;
	  break;
  case 6:
	  a=c=d=e=f=g=1;
	  b=0;
  case 7:
	  a=b=c=f=1;
	  e=d=g=0;
	  break;
  case 8:
	  a=b=c=d=e=f=g=1;
	  break;
  case 9:
	  a=b=c=d=f=g=1;
	  e=0;
	  break;
  }*/
	a=b=c=d=e=f=g=0;
	da=a;db=b;dc=c;dd=d;de=e;df=f;dg=g;
	//printf("%d%d%d%d%d%d%d%d\n",g,f,e,d,c,b,a);
}

void seg::set(int num){
	switch(num){
	case 0:
		a = signal(&da,1);
		b = signal(&db,1);
		c = signal(&dc,1);
		d = signal(&dd,1);
		e = signal(&de,1);
		f = signal(&df,1);
		g = signal(&dg,0);
		break;
	case 1:
		a = signal(&da,0);
		b = signal(&db,1);
		c = signal(&dc,1);
		d = signal(&dd,0);
		e = signal(&de,0);
		f = signal(&df,0);
		g = signal(&dg,0);
		break;
	case 2:
		a = signal(&da,1);
		b = signal(&db,1);
		c = signal(&dc,0);
		d = signal(&dd,1);
		e = signal(&de,1);
		f = signal(&df,0);
		g = signal(&dg,1);
		break;
	case 3:
		a = signal(&da,1);
		b = signal(&db,1);
		c = signal(&dc,1);
		d = signal(&dd,1);
		e = signal(&de,0);
		f = signal(&df,0);
		g = signal(&dg,1);
		break;
	case 4:
		a = signal(&da,0);
		b = signal(&db,1);
		c = signal(&dc,1);
		d = signal(&dd,0);
		e = signal(&de,0);
		f = signal(&df,1);
		g = signal(&dg,1);
		break;
	case 5:
		a = signal(&da,1);
		b = signal(&db,0);
		c = signal(&dc,1);
		d = signal(&dd,1);
		e = signal(&de,0);
		f = signal(&df,1);
		g = signal(&dg,1);
		break;
	case 6:
		a = signal(&da,1);
		b = signal(&db,0);
		c = signal(&dc,1);
		d = signal(&dd,1);
		e = signal(&de,1);
		f = signal(&df,1);
		g = signal(&dg,1);
		break;
	case 7:
		a = signal(&da,1);
		b = signal(&db,1);
		c = signal(&dc,1);
		d = signal(&dd,0);
		e = signal(&de,0);
		f = signal(&df,1);
		g = signal(&dg,0);
		break;
	case 8:
		a = signal(&da,1);
		b = signal(&db,1);
		c = signal(&dc,1);
		d = signal(&dd,1);
		e = signal(&de,1);
		f = signal(&df,1);
		g = signal(&dg,1);
		break;
	case 9:
		a = signal(&da,1);
		b = signal(&db,1);
		c = signal(&dc,1);
		d = signal(&dd,1);
		e = signal(&de,0);
		f = signal(&df,1);
		g = signal(&dg,1);
		break;
	}
	printf("%d%d%d%d%d%d%d\n",g,f,e,d,c,b,a);
	printf("%d%d%d%d%d%d%d\n",dg,df,de,dd,dc,db,da);
}

	
int main(){
	int num,n;
	seg seg;
	seg.empty();
	scanf("%d",&n);
	while(n!=-1){
		while(n--){
			scanf("%d",&num);
			seg.set(num);
		}
		seg.empty();
		scanf("%d",&n);
	}
	return 0;
}

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

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

   return 0;
}

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("0100111"); // 7
    seg.push_back("1111111"); // 8
    seg.push_back("1101111"); // 9


  while(cin >> n && n!=-1){
    //    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 <iostream>

using namespace std;

int main(void){
  int ans[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 n;
  while(cin>>n,n>0){
    int number;
    int now[7]={0,0,0,0,0,0};
    for(int j = 0 ; j < n ; j ++){
      cin>>number;
      for(int i = 0 ; i < 7 ; i ++){
        cout<<(ans[number][i]==now[i]?0:1);
        now[i]=ans[number][i];
      }
      cout<<endl;
    }
  }
}

C++: #include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int a[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,1,0,1,1,1,1}};
  int b[7],c[100],n;
  while(cin>>n&&n!=-1){
    for(i=0;i<n;i++)
      cin>>c[i];
    memset(b,0,sizeof(b));
    for(i=0;i<n;i++){
      for(j=0;j<7;j++){
	cout<<(b[j]^a[c[i]][j]);
	b[j]=(b[j]+(b[j]^a[c[i]][j]))%2;
      }
      cout<<endl;
    }
  }
  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] = "1100001";
	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;
}