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 <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>
using namespace std;

int main() {
    int j,n,a,b;
    int d[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}};
    while(cin >> n && n!=-1) {
		for (a=10;n>0;n--) { cin >> b;
		for (j=0;j<7;j++) cout << (d[a][j]+d[b][j]) % 2;
		a=b; 
		cout << endl;}
	}
	return 0;
}

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

char **s;
int m,n,o,set[10] = {63,6,91,79,102,109,125,39,127,111};

void IntToBinary(int a, char *s){
	int b = a;
	for(int i=6; i>=0; i--){
		if(b >= pow(2.0,i)){
			b -= pow(2.0,i);
			s[6-i] = '1';
		}else
			s[6-i] = '0';
	}
	s[7] = '\0';
}

int main(){
	while(true){
		std::cin >> n;
		if(n == -1)
			return 0;
		s = new char*[n];
		for(int i=0; i<n; i++)
			s[i] = new char[8];
		std::cin >> m;
		IntToBinary(set[m], s[0]);
		for(int i=1; i<n; i++){
			std::cin >> o;
			IntToBinary(set[m]^set[o], s[i]);
			m = o;
		}
		for(int i=0; i<n; i++){
			std::cout << s[i] << std::endl;
			delete[] s[i];
		}
		delete[] s;
	}
}

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

using namespace std;

int main(void){

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

  while( cin >> n , n >= 0 ){

    int A,B;    
    cin >> A;
    cout << bit[A] << endl;
    n--;

    while(n--){
      cin >> B;
      for( int i = 0 ; i < 7 ; i++ ){
	if( bit[A][i] == bit[B][i] ){
	  cout << "0";
	}
	else cout << "1";
      }
      cout << endl;
      A = B;
    }
  }
  return 0;
}

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

using namespace std;

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

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

int nikara (const string &sig);
void tenkara ( int );

int main () {
	string sig[10] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
	string before,hoge;
	int n,num;
	int var = 0x0001;
	int bvar,piyo;
	
	while ( cin >> n, n != -1 ){
		bvar = 0;
		for ( int i = 0; i < n; i++ ) {
			cin >> num;
			hoge = sig[num];
			
			var = nikara ( hoge );
			piyo = var ^ bvar;
			tenkara ( piyo );
			
			bvar = var;
		}
	}
}

int nikara (const string &sig) {
	int out = 0;
	for (int i = 0, size = sig.size(); i < size ; ++i ) {
		out *= 2;
		out += ((int)sig[i] == 49) ? 1 : 0;
	}
	return out;
}

void tenkara (int hoge) {
	string sig;
	for ( int i = 0; i < 7; i++ ) {
		sig[i] = hoge % 2 + '0';
		hoge = hoge / 2;
	}
	
	for ( int i = 6; i >= 0; i-- ) {
		cout << sig[i];
	}
	cout << endl;
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  string p[10];
  p[0] = "0111111";
  p[1] = "0000110";
  p[2] = "1011011";
  p[3] = "1001111";
  p[4] = "1100110";
  p[5] = "1101101";
  p[6] = "1111101";
  p[7] = "0100111";
  p[8] = "1111111";
  p[9] = "1101111";
  int N;
  while(cin >>N && N != -1){
    string s = "0000000";
    REP(nn, N){
      int n; cin >>n;
      REP(i, s.length()){
        if(s[i] == p[n][i]) cout <<"0";
        else{
          cout <<"1";
          s[i] = (s[i] == '1' ? '0' : '1');
        }
      }
      cout <<endl;
    }
  }
  return 0;
}

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

int main(){
	int n,i,a,j,b;
	string digit[10] = { "0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111" },str;
	while(1){
		str == "";
		cin >> n;
		if(n == -1) break;
		for(i = 0;i < n;++i){
			cin >> a;
			if(i == 0){
				cout << digit[a];
				str = digit[a];
			}
			else {
				for(j = 0;j < 7;++j){
					b = (int)(digit[a][j] - str[j]);
					if(b < 0) b *= -1;
					cout << b;
				}
				str = digit[a];
			}
			cout << "\n";
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  bitset<7> a[10];
  string num2[10]={"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
  for(int i=0;i<10;i++){
    a[i]=bitset<7>(num2[i]);
  }
  while(1){
    long long n,num;
    cin>>n;
    if(n==-1) break;
    bitset<7> now(0);
    for(int i=0;i<n;i++){
      cin>>num;
      bitset<7> out=now^a[num];
      cout<<(now^a[num])<<endl;
      now=a[num];
    }
  }
}