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 <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n;
    string segments[11] = {
        "0111111",
        "0000110",
        "1011011",
        "1001111",
        "1100110",
        "1101101",
        "1111101",
        "0100111",
        "1111111",
        "1101111",
        "0000000"};
    int before = 10;
    while(cin >> n, n!=-1){
        rep(i, n){
            int m;
            cin >> m;
            rep(i, segments[m].size()){
                if(segments[before][i] == segments[m][i]) cout << 0;
                else cout << 1;
            }
            cout << endl;
            before = m;
        }
    }
}

C++: #include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string now = "0000000";
string num[10] = {"0111111", "0000110", "1011011", "1001111", "1100110"
                 ,"1101101", "1111101", "0100111", "1111111", "1101111"};
string res;
signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    if(n == -1)break;

    res.resize(7);
    now = "0000000";
    rep(i, n){
      int(x);
      rep(j, 7){
        if(now[j] != num[x][j])res[j] = '1';
        else res[j] = '0';
        now[j] = num[x][j];
      }
      pri(res);
    }


//*/

//*/ break;
  }
  return 0;
}

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

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;
      }
    }
  }

  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(c)   (c).begin(),(c).end()
#define pb push_back
string a[10]={
  "1111110",
  "0110000",
  "1101101",
  "1111001",
  "0110011",
  "1011011",
  "1011111",
  "1110010",
  "1111111",
  "1111011"
};

main(){
  rep(i,10)reverse(ALL(a[i]));
  int n;
  while(cin>>n && n != -1){
    int last=0;
    string op="0000000";
    rep(tc,n){
      int now;
      string tmp;
      cin>>now;
      rep(i,op.size()){
	if(op[i] != a[now][i]){
	  tmp+="1";
	}else tmp+="0";
      }
      cout << tmp << endl;
      op=a[now];
    }

  }
  return false;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
string dectobin(int n){
	string bin;
	while(n){
		bin+='0'+(n%2);
		n/=2;
	}
	reverse(bin.begin(),bin.end());
	return bin;
}

int main() {
	int d,n;
	char current;
	char digit[10] = {63,6,91,79,102,109,125,39,127,111};
	
	while(cin>>n,n+1){
		current = 0;
		for(int i=0;i<n;++i){
			cin>>d;
			cout<<setfill('0')<<setw(7)<<dectobin((int)(current^digit[d]))<<endl;
			current = digit[d];
		}
	}
	return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int table[10] = {0x3f, 0x6, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x27, 0x7f, 0x6f};
	int n;
	int number;
	unsigned int data;
	
	while (1){
		data = 0;
		
		scanf("%d", &n);
		if (n == -1){
			break;
		}
		for (int i = 0; i < n; i++){
			unsigned int ans;
			scanf("%d", &number);
			
			ans = table[number] ^ data;
			for (int i = 0; i < 7; i++){
				printf("%d", ((ans >> (6 - i)) & 1));
			}
			data = table[number];
			
			puts("");
		}
	}
	
	return (0);
}