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++: // 0228
#include <iostream>
using namespace std;

int digit[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(){
	while(1){
		int n, num, display[7] = {0};

		cin>>n;
		if(n == -1)
			break;

		for(int i=0;i<n;i++){
			cin>>num;

			for(int j=0;j<7;j++){
				if(display[j] != digit[num][j])
					cout<<"1";
				else
					cout<<"0";

				display[j] = digit[num][j];
			}
			cout<<endl;
		}
	}
	return 0;
}

C++: 
#include<iostream>

using namespace std;

void setByte(bool *b, int n)
{
  static bool v[11][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},
     {0, 0, 0, 0, 0, 0, 0}};
  for(int i = 0; i < 7; i++)
    b[i] = v[n][i];
}

int main()
{
  bool state[7];
  bool b[7];
  int n;
  while(1)
  {
    setByte(state, 10);
    cin >> n;

    if(n == -1)
      break;

    for(int i = 0; i < n; i++)
    {
      int d;
      cin >> d;
      setByte(b, d);

      for(int j = 0; j < 7; j++)
      {
        state[j] = !(state[j] == b[j]);
        cout << state[j];
      }
      cout << endl;
      setByte(state, d);
    }
  }
}

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

int seg[10] = {63,6,91,79,102,109,125,39,127,111};

int main() {
	int n, m;
	while (cin >> n, 0 <= n) {
		bitset<7> b(0);
		for (int i=0; i<n; ++i) {
			cin >> m;
			b ^= bitset<7>(seg[m]);
			cout << b << endl;
			b = bitset<7>(seg[m]);
		}
	}
	return 0;
}

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

int main(){
    int n,nm[100];
    
    while(true){
        string first = "0000000";
        
        cin >> n;
        if(n == -1) break;
        
        for(int i = 0 ; i < n ; i++){
            cin >> nm[i];
            
            string str;
            switch(nm[i]){
                case 0:
                    str = "0111111";
                    break;
                case 1:
                    str = "0000110";
                    break;
                case 2:
                    str = "1011011";
                    break;
                case 3:
                    str = "1001111";
                    break;
                case 4:
                    str = "1100110";
                    break;
                case 5:
                    str = "1101101";
                    break;
                case 6:
                    str = "1111101";
                    break;
                case 7:
                    str = "0100111";
                    break;
                case 8:
                    str = "1111111";
                    break;
                case 9:
                    str = "1101111";
                    break;
            }
            string ans = "";
            for(int j = 0 ; j < 7 ; j++){
                if(first[j]!= str[j]) ans += '1';
                else ans += '0';
            }
            cout << ans << endl;
            first = str;
        }
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

int disp[10] = {
0b1111110, 
0b0110000, 
0b1101101, 
0b1111001, 
0b0110011,
0b1011011, 
0b1011111, 
0b1110010, 
0b1111111, 
0b1111011,};

int main(){
	while(true){
		int n;
		cin>>n;
		if(n==-1) break;
		
		int state = 0;
		REP(i, n){
			int x;
			cin>>x;
			int a = disp[x];
			int c = state ^ a;
			REP(i, 7) printf("%d", (c>>i)%2);
			printf("\n");
			state = a;
		}
	}
}

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

void printBit(int x, int w){
    if (!w) return;
    printBit(x/2, w-1);
    cout << x%2;
}

main(){
    int B[11] = {63, 6, 91, 79, 102, 109, 125, 39, 127, 111, 0};
    int n, p;
    while( cin >> n && n != -1 ){
	for ( int i = 0, cur = 10; i < n; i++ ){
	    cin >> p;
	    printBit(B[cur]^B[p], 7);
	    cout << endl;
	    cur = p;
	}
    }
}

C++: #include <iostream>

using namespace std;

const string num[11] = {"0111111", "0000110", "1011011",
                        "1001111", "1100110", "1101101",
                        "1111101", "0100111", "1111111",
                        "1101111", "0000000"};
int main()
{
    int n;

    while (cin >> n, n != -1) {
        int bf = 10;

        for (int i = 0; i < n; i++) {
            int inp;
            string ans;

            cin >> inp;            
            for (int i = 0; i < 7; i++)
                if (num[inp][i] != num[bf][i]) 
                    ans.push_back('1');
                else
                    ans.push_back('0');
            cout << ans << endl;

            bf = inp;
        }
    }

    return 0;
}

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

using namespace std;

int main()
{
	string str1,str2[10];
	int n,a,i,j;
	
	str2[0]="0111111";
	str2[1]="0000110";
	str2[2]="1011011";
	str2[3]="1001111";
	str2[4]="1100110";
	str2[5]="1101101";
	str2[6]="1111101";
	str2[7]="0100111";
	str2[8]="1111111";
	str2[9]="1101111";
	
	for(;;)
	{
		cin >> n;
		if(n==-1)
			break;
		
		str1="0000000";
		for(i=0;i<n;i++)
		{
			cin >> a;
			for(j=0;j<7;j++)
			{
				if(str1[j]==str2[a][j])
					str1[j]='0';
				else
					str1[j]='1';
			}
			cout << str1 << endl;
			str1=str2[a];
		}
	}
}

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

int seg[] = {0x3f, 0x06, 0x5b, 0x4f, 0x66,
	0x6d, 0x7d, 0x27, 0x7f, 0x6f};

int main() {
	int n;
	while(cin >> n, n != -1) {
		int status = 0;
		for(int i = 0; i < n; i++) {
			int in;
			cin >> in;
			status ^= seg[in];
			for(int i = 6; i >= 0; i--) {
				cout << !!(status & (1 << i));
			}
			cout << endl;
			status = seg[in];
		}
	}
}

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