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 <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#include <bitset>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
string a[]={
	"0111111",
	"0000110",
	"1011011",
	"1001111",
	"1100110",
	"1101101",
	"1111101",
	"0100111",
	"1111111",
	"1101111"
};
int main(){
	int n;
	while(cin>>n){
		string pos="0000000";
		if(n==-1)break;
		for(int i =0;i <n;i++){
			int x;
			cin>>x;
			string tmp =a[x];
			string str1="";
			for(int j =0;j <tmp.length();j++){
				if(pos[j]==tmp[j]){
					str1 +="0";
				}else{
					str1 +="1";
				}
			}
			cout <<str1<<endl;
			pos =a[x];
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main()
{
	string num[] = { "0111111", "0000110", "1011011", "1001111",
		"1100110", "1101101", "1111101", "0100111",
		"1111111", "1101111", "1000110" };
	int n,a;
	string s,t;
	while (true){
		cin >> n;
		if (n == -1){
			break;
		}
		cin >> a;
		s = num[a];
		cout << s << endl;
		for (int i = 0; i < n - 1; i++){
			cin >> a;
			for (int i2 = 0; i2 < num[a].size(); i2++){
				if (s[i2] != num[a][i2]){
					t += '1';
				}
				else{
					t += '0';
				}
			}
			cout << t << endl;
			s = num[a];
			t.clear();
		}
	}
}

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

int main(){
	string seg[10] =
	{
	"0111111","0000110","1011011","1001111","1100110",
	"1101101","1111101","0100111","1111111","1101111"
	};
	int n;
	while(1){
		cin >> n;
		if(n == -1) break;
		int cou = n;
		string now;
		while(cou--){
			int num; cin >> num;
			if(cou == n-1) {
				cout << seg[num] << endl;
				now = seg[num];
			}
			else {
				for(int i=0;i<7;i++){
					if(now[i] == seg[num][i]) cout << "0";
					else cout << "1";
				}
				cout << endl;
				now = seg[num];
			}
		}
	}
}

C++: #include <iostream>

using namespace std;

int ss[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, 0, 1, 1, 1, 1, 1 }
};

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == -1) return 0;
    int d[7] = {0};
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      for (int j = 0; j < 7; j++) {
        cout << (d[j] ^ ss[x][j]);
        d[j] = ss[x][j];
      }
      cout << endl;
    }
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    int n; cin >> n;
    int dis = 0b0000000;
    while(n!=-1){
        vector<int> seg = {0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,
                           0b1101101,0b1111101,0b0100111,0b1111111,0b1101111};
        for(int i=0;i<n;i++){
            int d; cin >> d;
            int next;
            next = seg[d];
            int ans;
            ans = dis^next;
            dis = next;
            cout << bitset<7>(ans) << endl;
        }
        dis = 0b0000000;
        cin >> n;
    }
}

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

int main(void){
	int n = 0,in;
	int array[][8] ={
		{0,1,1,1,1,1,1}, // 0
		{0,0,0,0,1,1,0},
		{1,0,1,1,0,1,1},
		{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 box[] = {0,0,0,0,0,0,0};
	while(cin>>n,n!=-1){

		int box[] = {0,0,0,0,0,0,0};
		while(n--){
			cin>>in;
			for(int i = 0 ; i < 7 ; i ++){
				cout<<(box[i] != array[in][i]?1:0);
				box[i] = array[in][i];
			}
			cout<<endl;
		}
	}
}

C++: #include <bits/stdc++.h>

typedef long long ll;
using namespace std;

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

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



	while(1){
		string s = "0000000";
		int n; cin >> n;
		if(n == -1) break;
		for (int i = 0;i < n;i++){
			int next;cin >> next;
			string ans = "0000000";
			for (int i = 0;i < 7;i++){
				if(s[i] == num[next][i])ans[i] = '0';
				else ans[i] = '1';
			}
			s = num[next];
			cout << ans << endl;
		}
	}

	return 0;

}

C++: #include <iostream>
#include <algorithm>
#include <string>

const int V[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}
};

using namespace std;

typedef long long ll;
typedef long double ld;

string change(int a, int b) {
  string res = "";
  for(int i=0; i<7; i++){
    if(V[a][i] == V[b][i]) {
      res += "0";
    } else {
      res += "1";
    }
  }

  return res;
}
  
int main() {
  int n, f=-1, t;

  while(true) {
    cin >> n;
    if(n == -1) break;
    for(int i=0; i<n; i++) {
      cin >> t;
      if(f == -1) {
        for(int j=0; j<7; j++) {
          cout << V[t][j];
        }
        cout << endl;
        f = t;
      } else {
        cout << change(f, t) << endl;
        f = t;
      }
    
    f = -1;
  }

  return 0;
}