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

int main()
{
	int n;
	string num[] = {
		"0111111",
		"0000110",
		"1011011",
		"1001111",
		"1100110",
		"1101101",
		"1111101",
		"0100111",
		"1111111",
		"1101111"
	};
	
	while (scanf("%d", &n), n != -1){
		int input;
		char str[10] = {'0'};
		char diff[10] = {'0'};
			
		for (int i = 0; i < n; i++){
			
			scanf("%d", &input);
			
			for (int j = 0; j < 7; j++){
				if (input == 0){
					
					//printf(" %s %s\n", str, num[0].c_str());
					
					if (str[j] == num[0][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[0][j];
					}
				}
				else if (input == 1){
					
					if (str[j] == num[1][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[1][j];
					}
				}
				else if (input == 2){
					if (str[j] == num[2][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[2][j];
					}
				}
				else if (input == 3){
					if (str[j] == num[3][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[3][j];
					}
				}
				else if (input == 4){
					if (str[j] == num[4][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[4][j];
					}
				}
				else if (input == 5){
					if (str[j] == num[5][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[5][j];
					}
				}
				else if (input == 6){
					if (str[j] == num[6][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[6][j];
					}
				}
				else if (input == 7){
					if (str[j] == num[7][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[7][j];
					}
				}
				else if (input == 8){
					if (str[j] == num[8][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[8][j];
					}
				}
				else if (input == 9){
					if (str[j] == num[9][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[9][j];
					}
				}
			}
			printf("%s\n", diff);
		}
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,l[101][101],m;
  fill(l[0],l[0]+101,0);
  while(cin >> n,n+1){
    for(int i = 1;i <= n;i++){
      cin >> m;
      if(m>1&&m!=7) l[i][0] = 1;
      else l[i][0] = 0;
      if(m<4&&m>0) l[i][1] = 0;
      else l[i][1] = 1;
      if(m%2==0&&m!=4) l[i][2] = 1;
      else l[i][2] = 0;
      if(m==1||m==4||m==7) l[i][3] = 0;
      else l[i][3] = 1;
      if(m==2) l[i][4] = 0;
      else l[i][4] = 1;
      if(m==5||m==6) l[i][5] = 0;
      else l[i][5] = 1;
      if(m==1||m==4) l[i][6] = 0;
      else l[i][6] = 1;
      for(int j = 0;j <= 6;j++){
	if(l[i][j] == l[i-1][j]) cout << 0;
	else cout << 1;
      }
      cout << endl;
    }
  }
  return (0);
}

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

using namespace std;

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

C++: #include<iostream>
using namespace std;int main(){int m[10][7];for(int i=0;i<10;i++)for(int j=0;j<7;j++)m[i][j]=1;m[0][6]=0,m[1][0]=0,m[1][3]=0,m[1][4]=0,m[1][5]=0,m[1][6]=0,m[2][2]=0,m[2][5]=0,m[3][4]=0,m[3][5]=0,m[4][0]=0,m[4][3]=0,m[4][4]=0,m[5][1]=0,m[5][4]=0,m[6][1]=0,m[7][3]=0,m[7][4]=0,m[7][6]=0,m[9][4]=0;int n,a,set;while(true){cin>>n;if(n==-1)break;cin>>set;for(int i=6;i>=0;i--)cout<<m[set][i];cout<<endl;for(int i=1;i<n;i++){cin>>a;for(int i=6;i>=0;i--)cout<<abs(m[set][i]-m[a][i]);cout<<endl;set=a;}}return 0;}

C++: #include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
int main(){
	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 n, a;
	while(cin >> n) {
		if(n==-1) break;
		int x[7] = {0,0,0,0,0,0,0};
		rep(i,n) {
			cin >> a;
			rep(j,7) {
				int y = digit[a][j]^x[j];
				cout << y;
			}
			cout << endl;
			rep(j,7) x[j] = digit[a][j];
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

string seg[] = {
	"1111110",
	"0110000",
	"1101101",
	"1111001",
	"0110011",
	"1011011",
	"1011111",
	"1110010",
	"1111111",
	"1111011",
};

int main(){
	bitset<7> sevensegs[10];
	rep(i, 10){
		sevensegs[i] = bitset<7>(string(rev(seg[i])));
	}

	int n;
	while(cin >> n, n != -1){
		bitset<7> state, change;
		rep(i, n){
			int num;
			cin >> num;
			change = state^sevensegs[num];
			state ^= change;
			cout << change << endl;
		}
	}

	return 0;
}

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"};
    while(cin >> n, n!=-1){
        int before = 10;
        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 <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

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

int main(){
	while(cin>>n&&n!=-1){
		int c=0,m;
		rep(i,n){
			cin>>m;
			rep(i,7)cout<<((c^s[m])/(int)pow(2.0,6-i))%2;cout<<endl;
			c=s[m];
		}
	}
}