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<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))


int main(){
	int n,t;
	char v[10]={63,6,91,79,102,109,125,39,127,111};
	char s[8],a,b;
	for(;;){
		scanf("%d",&n);
		if(n==-1)break;
		a=0;
		rep(i,n){
			scanf("%d",&t);
			b=a^v[t];
			a=v[t];
			rep(j,7)printf("%d",(b & (1<<(6-j))) > 0);
			puts("");
		}
	}
	return 0;
}

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

const string numbers[10] = {
    "0111111",
    "0000110",
    "1011011",
    "1001111",
    "1100110",
    "1101101",
    "1111101",
    "0100111",
    "1111111",
    "1101111"
};

string convert( int k, string prev )
{
    string answer;
    for ( int i = 0; i < 7; i++ ) {
        if ( numbers[k][i] == prev[i] ) {
            answer += '0';
        } else {
            answer += '1';
        }
    }
    return answer;
}

int main( void )
{
    int n;
    while ( cin >> n && n != -1 ) {
        string prev = "000000";
        for ( int i = 0; i < n; i++ ) {
            int k;
            cin >> k;
            cout << convert( k, prev ) << endl;
            prev = numbers[k];
        }
    }
    return 0;
}

C++: 
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

bitset<7> num[10] = { 126, 48, 109, 121, 51, 91, 95, 114, 127, 123};

int main()
{
	int n;
	while(cin >> n && n + 1)
	{
		bitset<7> prv;

		rep(i, n)
		{
			int in;
			cin >> in;

			bitset<7> buf = (num[in] ^ prv);
			
			rep(i, 7)
				cout << buf[i] << (i == 6 ? "\n" : "");

			prv = num[in];
		}
	}
}

C++: #include<cstdio>

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

using namespace std;

int main(){
	int bit[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x27,0x7f,0x6f};

	for(int n;scanf("%d",&n),~n;){
		int stat=0;
		rep(i,n){
			int a;	scanf("%d",&a);
			int dif=stat^bit[a];
			stat=bit[a];

			rep(j,7)	printf("%d",(bool)(dif&(1<<(6-j))));
			putchar('\n');
		}
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

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

int main(){
	
	int n;
	
	while(true){
		
		cin >> n;
		
		if(n == -1){
			break;
		}
		
		string cur_num = "0000000";
		
		for(int i = 0; i < n; i++){
			int num;
			cin >> num;
			
			for(int j = 0; j < 7; j++){
				if(cur_num[j] != str[num][j]){
					cout << "1";
				}else{
					cout << "0";
				}
			}
			cout << endl;
			cur_num = str[num];
		}
		
		
		
	}
	
	return 0;
}

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

string diff(string now,string bit)
{
  string ans="0000000";
  for(int i=0;i<7;i++){
    //  cout<<(now[i]-'0')<<endl;
   // cout<<(bit[i]-'0')<<endl; 
   // cout<<((now[i]-'0') ^ (bit[i]-'0'))<<endl; 
    ans[i]=((now[i]-'0') ^ (bit[i]-'0'))+'0'; 
  }  
  return ans;
}

int main()
{
  string bit[10]={
    "1111110",
    "0110000",
    "1101101",
    "1111001",
    "0110011",
    "1011011",
    "1011111",
    "1110010",
    "1111111",
    "1111011"
  };
  
  int n;
  for(;cin>>n,n!=-1;)
    {
      string now="00000000";
      for(int i=0;i<n;i++)
	{
	  int tar;
	  cin>>tar;
	  string s=diff(now,bit[tar]);
	  reverse(s.begin(), s.end());
	  cout<<s<<endl;
	  now=bit[tar];
	}
    }

}

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

#define oct2dec( b ) ( \
 ((b & 1 <<  0) >>  0) + ((b & 1 <<  3) >>  2) + ((b & 1 <<  6) >>  4) + \
 ((b & 1 <<  9) >>  6) + ((b & 1 << 12) >>  8) + ((b & 1 << 15) >> 10) + \
 ((b & 1 << 18) >> 12) + ((b & 1 << 21) >> 14))

#define B( x ) oct2dec( 0 ## x )

const int en[10] = { B( 0111111 ), B( 0000110 ), B( 1011011 ), B( 1001111 ), B( 1100110 ), 
					B( 1101101 ), B( 1111101 ), B( 0100111 ), B( 1111111 ), B( 1101111 ) };

void showBin( int x )
{
	std::string s;

	while( x > 0 )
	{
		s += ( x & 1 ) + '0';
		x >>= 1;
	}

	std::reverse( s.begin(), s.end() );

	std::cout << std::setw( 7 ) << std::setfill( '0' ) << s << std::endl;

	return;
}

int main()
{
	int n;
	while( std::cin >> n, n != -1 )
	{
		int prv = 0;
		for( int i = 0; i != n; ++i )
		{
			int a;
			std::cin >> a;
			showBin( en[a] ^ prv );
			prv = en[a];
		}
	}

	return 0;
}

C++: #include <cstdio>

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

int main(){
	int lights[] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x27, 0x7f, 0x6f};
	int n = 0;
	while(scanf("%d", &n), ~n){
		int prev_light = 0;
		for(int i=n;i;i--){
			int j;
			scanf("%d", &j);
			binarywrite(prev_light ^ lights[j]);
			prev_light = lights[j];
		}
	}
	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(m = set[m], s[0]);
		for(int i=1; i<n; i++){
			std::cin >> o;
			IntToBinary(m = m^set[o], s[i]);
		}
		for(int i=0; i<n; i++){
			std::cout << s[i] << std::endl;
			delete[] s[i];
		}
		delete[] s;
	}
}

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

constexpr int D[]={
    0b0111111,
    0b0000110,
    0b1011011,
    0b1001111,
    0b1100110,
    0b1101101,
    0b1111101,
    0b0100111,
    0b1111111,
    0b1101111
};

bool solve(){
    int n;
    cin >> n;
    if(n == -1) return false;
    int S = 0;
    for(int i=0;i<n;i++){
        int d;
        cin >> d;
        cout << bitset<7>(S^D[d]) << endl;
        S = D[d]; 
    }
    return true;
}

int main() {
    while(solve());
    return 0;
}