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 <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
  int segment[] = {
    63, //(0111111)_2                                                                                                                                                     
    6,  //(0110000)_2                                                                                                                                                     
    91, //(1101101)_2                                                                                                                                                     
    79, //(1111001)_2                                                                                                                                                     
    102,//(0110011)_2                                                                                                                                                     
    109,//(1011011)_2                                                                                                                                                     
    125,//(1011111)_2                                                                                                                                                     
    39, //(1110010)_2                                                                                                                                                     
    127,//(1111111)_2                                                                                                                                                     
    111,//(1111011)_2                                                                                                                                                     
    0,  //(0000000)_2                                                                                                                                                     
  };
  const int Default = 10;
  int n, num;

  while (cin >> n, n != -1) {
    int before = Default;
    int change;
    for (int i = 0; i < n; i++) {
      cin >> num;
      change = segment[before] ^ segment[num];
      for (int j = 0; j < 7; j++) {
        cout << (change & 64 ? 1 : 0);
        change <<= 1;
      }
      before = num;
      cout << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <cstring>

using namespace std;

int main()
{
  int n, c;
  const int num[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, 0},
    {0, 1, 0, 0, 1, 1, 1},
    {1, 1, 1, 1, 1, 1, 1},
    {1, 1, 0, 1, 1, 1, 1}
  };

  while (cin >> n, n != -1){
    int seg[] = {0, 0, 0, 0, 0, 0, 0};
    while (n--){
      cin >> c;
      for (int i = 0; i < 7; i++){
        if (seg[i] != num[c][i]){
          seg[i] = 1;
        }
        else {
          seg[i] = 0;
        }
        cout << seg[i];
		seg[i] = num[c][i];
      }
      cout << endl;
    }
  }

  return (0);
}

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

vector<string> l = {
  "0111111",
  "0000110",
  "1011011",
  "1001111",
  "1100110",
  "1101101",
  "1111101",
  "0100111",
  "1111111",
  "1101111",
  "0000000"
};

string change(int now ,int nxt){
  string s = "";
  for(int i=0;i<l[now].size();i++){
    if(l[now][i]!=l[nxt][i]){
      s += '1';
    }else{
      s+='0';
    }
  }
  return s;
}

int solve(){
  int now = 10;
  int n = 0;
  cin>>n;
  if(n==-1)return false;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    cout<<change(now,tmp)<<endl;
    now = tmp;
  }
  return 1;
}

int main(){
  while(solve());
}

C++: #include<bits/stdc++.h>
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 <string>

using namespace std;

int main(void){
	string state[10];
	int n;
	
	state[0] = "0111111";
	state[1] = "0000110";
	state[2] = "1011011";
	state[3] = "1001111";
	state[4] = "1100110";
	state[5] = "1101101";
	state[6] = "1111101";
	state[7] = "0100111";
	state[8] = "1111111";
	state[9] = "1101111";
	
	while(cin >> n && n != -1){
		string cur = "0000000";
		string out = "0000000";
		int t;
		for(int i=0;i<n;i++){
			cin >> t;
			for(int i=0;i<7;i++){
				cur[i] == state[t][i]?out[i]='0':out[i]='1';
			}
			cout << out <<endl;
			cur = state[t];
		}
	}
}

C++: #include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
void solve(int m);       //データの処理
void clear(void);            //segment[0]の初期化

int n,m;                 //数字の個数,数字
int segment[11][7]=      //各セグメントに対応するbitの状態
  /*{g,f,e,d,c,b,a}*/
  {
    {0,0,0,0,0,0,0},     //変化させる配列
    {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(){

  int i,j;

  while(1){

  /*数字の個数nの入力*/
  scanf("%d",&n);

  if(n==-1)break;

  /*n個の数字を入力*/
  for(i=0;i<n;i++){
    scanf("%d",&m);

    /*データの処理*/
    solve(m);

  }

  /*segment[0]を0で初期化*/
  clear();
  
  }

  return 0;
}
/*データ処理*/
void solve(int m){

  int i,j;

  /*segment[m+1]からsegment[0]を引いたときそのbitが0以外なら1にする*/
  for(i=0;i<7;i++){
    segment[0][i]=segment[m+1][i]-segment[0][i];
    if(segment[0][i]==-1){
      segment[0][i]=1;
    }
  }

  /*結果の出力*/
  for(i=0;i<7;i++){
    printf("%d",segment[0][i]);
  }

  printf("\n");

  /*segment[0]をsegment[m+1]に初期化する*/
  for(i=0;i<7;i++){
    segment[0][i]=segment[m+1][i];
  }

}
/*segment[0]を0で初期化*/
void clear(){

  int i;

  for(i=0;i<7;i++){
    segment[0][i]=0;
  }

}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	string q[10]={
	"0111111",
	"0000110",
	"1011011",
	"1001111",
	"1100110",
	"1101101",
	"1111101",
	"0100111",
	"1111111",
	"1101111",
	};
	int n;
	while(cin>>n,n+1){
		string s="0000000";
		rep(i,n){
			int a;
			cin>>a;
			rep(i,7)cout<<(s[i]!=q[a][i]);
			cout<<endl;
			s=q[a];
		}
	}
}