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 <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;
int n, m;
vector<int> vege;

const int INF = 1 << 29;

int main(void)
{
	//0111111 0000110 1011011 1001111 1100110 1101101 1111101 0100111 1111111 1101111
	int memo[] = {127 - 64, 6, 64 + 16 + 8 + 2 + 1, 64 + 15, 64 + 32 +4 + 2,64+32+8+4+1,127-2, 32+7,127,127-16 };
	int nisin[] = {64, 32, 16, 8, 4, 2, 1};
	while(cin >> n && n != -1)
	{
		int bit = 0;
		for (int i = 0; i < n; i++)
		{
			int a;
			cin >> a;
			int ans = bit ^ memo[a];
			bit = memo[a];
			for (int j = 0; j < 7; j++)
			{
				if(ans >= nisin[j])
				{
					ans -= nisin[j];
					cout << 1;
				}
				else cout << 0;
			}
			cout << endl;
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string show[]={"0111111","0000110","1011011",
    "1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
    while(cin>>n&&n!=-1){
        string str="0000000";
        for(int i=0,num;i<n;i++){
            cin>>num;
            for(int j=0;j<7;j++){
                if(str[j]==show[num][j])cout<<"0";
                else cout<<"1";
            }
            cout<<endl;
            str=show[num];
        }
    }
}

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

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

int main()
{
    int c, n;
    while(cin >> c && c > 0) {
        string s = "0000000";
        for(int i = 0; i < c; i++) {
            cin >> n;
            string op = "0000000";
            for(int k = 0; k < 7; k++) {
                if(s[k] == segment[n][k]) {
                    op[k] = '0';
                } else {
                    op[k] = '1';
                }
            }
            s = segment[n];
            cout << op << endl;
        }
    }
}

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

int main() {
  int M[10];
  int N; const int ALL = (1<<7)-1;
  M[0] = ALL-(1<<6);
  M[1] = (1<<1)+(1<<2);
  M[2] = ALL-(1<<2)-(1<<5);
  M[3] = ALL-(1<<4)-(1<<5);
  M[4] = (1<<1)+(1<<2)+(1<<5)+(1<<6);
  M[5] = ALL-(1<<1)-(1<<4);
  M[6] = ALL-(1<<1);
  M[7] = ALL-(1<<3)-(1<<4)-(1<<6);
  M[8] = ALL;
  M[9] = ALL-(1<<4);
  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=6; j>=0; j--) {
        cout << (S >> j & 1);
      }
      S = M[x];
      cout << endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    char num[10][8] = {
        {"0111111"},
        {"0000110"},
        {"1011011"},
        {"1001111"},
        {"1001111"},
        {"1101101"},
        {"1111101"},
        {"1111101"},
        {"1111111"},
        {"1101111"}
    };
    while(cin >> n, n != -1){
        char display[8] = {"0000000"};
        while(n--){
            int inp;
            cin >> inp;
            rep(i,7){
                if(display[i] == num[inp][i]){
                    cout << '0';
                }else{
                    cout << '1';
                }
            }
            cout << endl;
            strcpy(display, num[inp]);
        }
    }
}

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

int t[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,a,b;
int main(){

  while(1){
    cin>>n;
    if(n==-1)break;
    cin>>a;
    for(int i=6;i>=0;i--)cout<<t[a][i];
    cout<<endl;
    for(int j=1;j<n;j++){
      b=a;
      cin>>a;
      for(int i=6;i>=0;i--){
	cout<<(t[a][i]!=t[b][i]?'1':'0');
      }
      cout<<endl;
    }
  }
  return 0;
}