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;
using ll = long long;
using pii = pair<int, int>;

int n;
string now;
string digit[10] = {
  "0111111",
  "0000110",
  "1011011",
  "1001111",
  "1100110",
  "1101101",
  "1111101",
  "0100111",
  "1111111",
  "1101111"
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> n, n >= 0) {
    now = "0000000";
    for (int i = 0; i < n; i++) {
      string ans(7, '0');
      int d;
      cin >> d;
      for (int j = 0; j < 7; j++) {
        if (now[j] == digit[d][j]) continue;
        ans[j] = '1';
      }
      cout << ans << endl;
      now = digit[d];
    }
  }  

  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>-1){
  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 <string>

using namespace std;

int main()
{
  int n, m;
  string s1, s2;

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

    s1 = "0000000";
    while(n--){
      cin >> m;
      if(m == 0){
	s2 = "0111111";
      } else if(m == 1){
	s2 = "0000110";
      } else if(m == 2){
	s2 = "1011011";
      } else if(m == 3){
	s2 = "1001111";
      } else if(m == 4){
	s2 = "1100110";
      } else if(m == 5){
	s2 = "1101101";
      } else if(m == 6){
	s2 = "1111101";
      } else if(m == 7){
	s2 = "0100111";
      } else if(m == 8){
	s2 = "1111111";
      } else {
	s2 = "1101111";
      }
      for(int i = 0; i < 7; i++){
	if(s1[i] == s2[i]){
	  cout << 0;
	} else {
	  cout << 1;
	}
      }
      cout << endl;
      s1 = s2;
    }

  }

  return 0;
}

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

using namespace std;

int main(){
  int j, i, n, previous, present;
  string answer, signal[11];

  signal[0] = "0111111";
  signal[1] = "0000110";
  signal[2] = "1011011";
  signal[3] = "1001111";
  signal[4] = "1100110";
  signal[5] = "1101101";
  signal[6] = "1111101";
  signal[7] = "0100111";
  signal[8] = "1111111";
  signal[9] = "1101111";
  signal[10] = "0000000";

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

    previous = 10;
    for(i=0; i<n; ++i){
      cin >> present;

      for(j=0; j<7; ++j){
	if(signal[present][j] == signal[previous][j])
	  cout << "0";
	else
	  cout << "1";
      }
      cout << endl;
      previous = present;
    }
  }

  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  int n,s;
  string san[11];
  san[0]="0111111"; 
  san[1]="0000110";
  san[2]="1011011";
  san[3]="1001111";
  san[4]="1100110";
  san[5]="1101101";
  san[6]="1111101";
  san[7]="0100111";
  san[8]="1111111";
  san[9]="1101111";
  while(cin>>n){
    if(n==-1) break;
    string mem="0000000";
    for(int i=0;i<n;i++){
      cin >> s;
      string a;
      for(int i=0;i<7;i++){
	if(san[s][i]==mem[i]) a += '0';
	  else a += '1';
	}
      cout << a << endl;
      mem = san[s];
    }
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>

using namespace std;





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

C++: #include <stdio.h>

void printBin(int n, int d);

int main(void){
    int ptn[] = {63, 6, 91, 79, 102, 109, 125, 39, 127, 111};
    int cur=0, next;
    
    while(scanf("%d",&next), next!=-1){
        printBin(cur^ptn[next], 7);
        printf("\n");
        cur = ptn[next];
    }
    return 0;
}

void printBin(int n, int d){
    for (d--; d>=0; d--){
        printf("%d", (n>>d)&1);
    } 
}

C++: 
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
int main()
{
	ios::sync_with_stdio(false);
	string a[10];
	a[0] = "0111111";
	a[1] = "0000110";
	a[2] = "1011011";
	a[3] = "1001111";
	a[4] = "1100001";
	a[5] = "1101101";
	a[7] = "0100111";
	a[6] = "1111101";
	a[8] = "1111111";
	a[9] = "1101111";
	while (true) {

		ll n;
		cin >> n;
		if (n == -1) { break; }
		string  s = "0000000";
		for (int i = 0; i < n; i++) {
			int d;
			cin >> d;
			for (int j = 0; j < 7; j++) {
				if (a[d][j] == s[j]) { cout << 0; }
				else { cout << 1; }
			}
			cout << endl;
			s = a[i];
		}
	
	}
	
	return 0;
}

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

union Segments {
    struct {
        unsigned int g: 1;
        unsigned int f: 1;
        unsigned int e: 1;
        unsigned int d: 1;
        unsigned int c: 1;
        unsigned int b: 1;
        unsigned int a: 1;
    } bit;
    unsigned int row;
};


ostream& operator<<(ostream& out, const Segments& s) {
    out << s.bit.g << s.bit.f << s.bit.e << s.bit.d << s.bit.c << s.bit.b << s.bit.a;
    return out;
}

Segments d[] = {
    {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, x;
    Segments display, sig;

    while (cin >> n, n != -1) {
        display.row = 0;
        while (n--) {
            cin >> x;
            sig.row = display.row ^ d[x].row;
            cout << sig << endl;
            display = d[x];
        }
    }
    return 0;
}