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++: // 2011/07/27 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int seg[11][7] = {{0,1,1,1,1,1,1},	// eÌf[^
	                  {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},
	                  {0,0,0,0,0,0,0}};	// seg[10]Íñ\¦

	while(true){
		int n;
		cin >> n;
		if(n==-1)
			break;

		int now = 10;		// ¡ÌiúlÍñ\¦j
		int nxt;		// Ì
		for(int i=0; i<n; i++){
			cin >> nxt;
			for(int j=0; j<7; j++)
				cout << (seg[now][j]+seg[nxt][j])%2;	// r¼I_a
			cout << endl;
			now = nxt;
		}
	}

	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main() {
	string date[11], now;
	date[0] = "1111110";
	date[1] = "0110000";
	date[2] = "0110000";
	date[3] = "1111001";
	date[4] = "0110011";
	date[5] = "1011011";
	date[6] = "1011111";
	date[7] = "1110010";
	date[8] = "1111111";
	date[9] = "1111011";
	int n, kazu;
	while (1) {
		now = "0000000";
		cin >> n;
		if (n == -1) goto a;
		for (int i = 1; i <= n; i++) {
			cin >> kazu;
			for (int z = 6; z >= 0; z--) {
				if (date[kazu][z] == now[z]) {
					cout << 0;
				}
				else {
					cout << 1;
					if (now[z] == '0') {
						now[z] = '1';
					}
					else {
						now[z] = '0';
					}
				}
			}
			cout << endl;
		}
	}
a:;
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int N;
char number[11][8] = {
		"0111111",//0
		"0000110",//1
		"1011011",//2
		"1001111",//3
		"1100110",//4
		"1101101",//5
		"1111101",//6
		"0100111",//7
		"1111111",//8
		"1101111",//9
		"0000000"//default
};

void func(){
	int num,pre = 10;

	for(int loop = 0; loop < N; loop++){
		scanf("%d",&num);

		for(int i = 0; i <= 6; i++){
			if(number[num][i] == number[pre][i]){
				printf("0");
			}else{
				printf("1");
			}
		}
		printf("\n");
		pre = num;
	}

}


int main(){

	while(true){
		scanf("%d",&N);
		if(N == -1)break;

		func();
	}

	return 0;
}

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


using namespace std;

string bit[12] = {
  "0111111", /*0*/
  "0000110", /*1*/
  "1011011", /*2*/
  "1001111", /*3*/
  "1100110", /*4*/
  "1101101", /*5*/
  "1111101", /*6*/
  "0100111", /*7*/ 
  "1111111", /*8*/
  "1101111", /*9*/
  "0000000"  /*pre*/
};





int main(){
  int n,in;
  while(true){
    cin >> n;
    if(n == -1)break;
    int pre = 10;
    for(int i=0;i<n;i++){   
      cin >> in;
      for(int i=0;i<7;i++){
	if(bit[pre][i] != bit[in][i]){
	  cout << '1';
	}
	else cout << '0';
      }
      cout << endl;
      pre = in;
    }
  }
  return 0;
}

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

int main(){
  int n, s;
  string seg[10] = {
    "0111111", "0000110","1011011", "1001111", "1100110","1101101","1111101",
    "0111111", "1111111","1101111"
  };

  while(cin >> n){
    if(n < 0) 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];
    }
  }
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int A=1, B=2, C=4, D=8, E=16, F=32, G=64;

int sig[10];


int main()
{
    sig[0] =1 + B*1 + C*1 + D*1 + E*1 + F*1 + G*0;
    sig[1] =0 + B*1 + C*1 + D*0 + E*0 + F*0 + G*0;
    sig[2] =1 + B*1 + C*0 + D*1 + E*1 + F*0 + G*0;
    sig[3] =1 + B*1 + C*1 + D*1 + E*0 + F*0 + G*1;
    sig[4] =0 + B*1 + C*1 + D*0 + E*0 + F*1 + G*1;
    sig[5] =1 + B*0 + C*1 + D*1 + E*0 + F*1 + G*1;
    sig[6] =1 + B*0 + C*1 + D*1 + E*1 + F*1 + G*1;
    sig[7] =1 + B*1 + C*1 + D*0 + E*0 + F*1 + G*0;
    sig[8] =1 + B*1 + C*1 + D*1 + E*1 + F*1 + G*1;
    sig[9] =1 + B*1 + C*1 + D*1 + E*0 + F*1 + G*1;

    //REP(10) cout << i << ":" << sig[i] << endl;
    int n;
    while(cin >> n )
    {
        if(n== -1) break;
        int disp = 0, next = 0, ans = 0;
        REP(n)
        {
            cin >> next;
            ans = sig[next]^disp;
            //cout << "ans" << ans << endl;
            rep(j,7)cout << (ans>>(6-j) & 1);
            cout << endl;
            disp = sig[next];
        }
        
    }
    return 0;
}

C++: #include<iostream>
#include<bitset>
using namespace std;
int henkan1(int x) {
	int y;
	switch (x) {
	case 0:y = 0b0111111; break;
	case 1:y = 0b0000110; break;
	case 2:y = 0b1011011; break;
	case 3:y = 0b1001111; break;
	case 4:y = 0b1100110; break;
	case 5:y = 0b1101101; break;
	case 6:y = 0b1111101; break;
	case 7:y = 0b0100111; break;
	case 8:y = 0b1111111; break;
	case 9:y = 0b1101111; break;
	default:break;
	}
	return y;
}
int henkan1(int x,int i) {
	if (!i)return 0;
	int y;
	switch (x) {
	case 0:y = 0b0111111; break;
	case 1:y = 0b0000110; break;
	case 2:y = 0b1011011; break;
	case 3:y = 0b1001111; break;
	case 4:y = 0b1100110; break;
	case 5:y = 0b1101101; break;
	case 6:y = 0b1111101; break;
	case 7:y = 0b0100111; break;
	case 8:y = 0b1111111; break;
	case 9:y = 0b1101111; break;
	default:break;
	}
	return y;
}
int henkan2(int x, int y,int i) {
	return henkan1(x,i) ^ henkan1(y);
}
int main() {
	int n;
	while (true) {
		cin >> n;
		if (n == -1)return 0;
		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> y;
			cout << static_cast<bitset<7>>(henkan2(x, y, i)) << endl;
			x = y;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
#define PI acos(-1)
using namespace std;
int def[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}
};
int main(){
  int n;
  while(cin>>n,n+1){
    int in;
    cin>>in;
    int now[7]={0};
    rep(i,7){
      now[i]=def[in][i];
      cout<<def[in][i];
    }
    cout<<endl;
    rep(i,n-1){
      cin>>in;
      rep(j,7){
	if(now[j]==def[in][j])cout<<0;
	else cout<<1;
	now[j]=def[in][j];
      }
      cout<<endl;
    }
  }


}