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<vector>
#include<string>
using namespace std;

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

    seg.push_back("0111111");
    seg.push_back("0000110");
    seg.push_back("1011011");
    seg.push_back("1001111");
    seg.push_back("1100110"); 
    seg.push_back("1101101"); 
    seg.push_back("1111101"); 
    seg.push_back("0111111");
    seg.push_back("1111111");
    seg.push_back("1101111");


  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;
const char* bits[] = {
	"0111111",
	"0000110",
	"1011011",
	"1001111",
	"1100110",
	"1101101",
	"1111101",
	"1001111",
	"0100111",
	"1111111",
	"1101111",
};

int main () {
	int n;
	while (cin >> n, n != -1) {
		char current[] = "0000000";
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			for (int i = 0; i < 7; i++) {
				if (current[i] != bits[x][i]) {
					cout << '1';
					current[i] = bits[x][i];
				}
				else {
					cout << '0';
				}
			}
			cout << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P,P> P2;
const int INF = 1 << 30;
const double EPS = 1E-9;

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

int main(){
	int n;
	while(cin >> n && n >= 0){
		string s = "0000000";
		int num;
		for(int i = 0; i < n; i++){
			cin >> num;
			string s2;
			string next = nums[num];
			for(int j = 0; j < 7; j++){
				if(next[j] == s[j]){
					s2.push_back('0');
				}else{
					s2.push_back('1');
				}
			}
			s = next;
			cout << s2 << endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>

void printBin(int n, int d);

int main(void){
    int ptn[] = {63, 6, 91, 79, 102, 109, 125, 39, 127, 111};
    int cur, next, n;
    
    while(scanf("%d",&n), n!=-1){
        cur=0;
        for (int i=0; i<n; i++){
            scanf("%d", &next);
            printBin(cur^ptn[next], 7);
            printf("\n");
            cur = ptn[next];
        }
    }
    return 0;
}

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

C++: #include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

int main(){
    
    string a[10];
    a[0] = "0111111";
    a[1] = "0000110";
    a[2] = "1011011";
    a[3] = "1001111";
    a[4] = "1100110";
    a[5] = "1101101";
    a[6] = "1111101";
    a[7] = "0100111";
    a[8] = "1111111";
    a[9] = "1101111";

    
    while(true){
        int tmp; cin >> tmp;
        if(tmp == -1) return 0;

        vi x;
        rep(i,tmp){
            int tmp2; cin >> tmp2;
            x.pb(tmp2);
        }
        cout << a[x[0]] << endl;
        rep(i,x.size()-1){
            string ans = "";

            rep(j,7){
                if(a[x[i]][j] == a[x[i+1]][j]){
                    ans += '0';
                }else{
                    ans += '1';
                }
            }
            cout << ans << endl;
        }
    }

    


}

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("0111111"); // 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 seg[10][7] = {
		{1,1,1,1,1,1,0},	// 0
		{0,1,1,0,0,0,0},	// 1
		{1,1,0,1,1,0,1},	// 2
		{1,1,1,1,0,0,1},	// 3
		{0,1,1,0,0,1,1},	// 4
		{1,0,1,1,0,1,1},	// 5
		{1,0,1,1,1,1,1},	// 6
		{1,1,1,0,0,1,0},	// 7
		{1,1,1,1,1,1,1},	// 8
		{1,1,1,1,0,1,1}		// 9
	};
	int n,m,b;

	while(cin >> n,n >= 0){
		int code[7];
		b = -1;
		while(--n, n>=0){
			cin >> m;

			if(b < 0)
				for(int i = 0; i < 7; i++)
					code[i] = seg[m][i];
			else
			for(int i = 0; i < 7; i++){
				code[i] = seg[m][i] ^ seg[b][i];
			}

			for(int i = 6; i >= 0; i--)
				cout <<  code[i];
			cout << endl;

			b = m;
		}
	}

	return 0;
}

C++: /*
	0228:Seven Segment
*/
#include	<iostream>
#include	<string>

using namespace std;

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

int main(void) {
	int n;
	while(1) {
		cin >> n;
		if(n == -1) { break; }
		string seg = "0000000";
		for(int i = 0; i < n; i++) {
			int sn;
			
			cin >> sn;
			for(int t = 0; t < 7; t++) {
				if(seg[t] == segNums[sn][t]) {
					cout << '0';
				} else {
					cout << '1';
				}
			}
			cout << endl;
			seg = segNums[sn];
		}
	}
}

C++: #include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n != -1)
	{
		string digits[10] = {"0111111", 
							 "0000110", 
							 "1011011", 
							 "1001111", 
							 "1100110", 
							 "1101101", 
							 "1111101", 
							 "0100111", 
							 "1111111", 
							 "1101111"};
		string current = "0000000";
		for(int i = 0; i < n; ++i)
		{
			int num;
			cin >> num;
			string ans = "";
			for(int j = 0; j < current.size(); ++j)
			{
				if(digits[num][j] == current[j])
				{
					cout << "0";
				}
				else
				{
					cout << "1";
					if(current[j] == '0')
					{
						current[j] = '1';
					}
					else
					{
						current[j] = '0';
					}
				}
			}
			cout << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}