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

int main(){
  vector<string> seg;
  int n, s, count=0, ago;
  string a,b,start;

    seg.push_back("0111111"); // 0
    seg.push_back("0000110"); // 1
    seg.push_back("1011011"); // 2
    seg.push_back("1001111"); // 3
    seg.push_back("1100110"); // 4 
    seg.push_back("1101101"); // 5 
    seg.push_back("1111101"); // 6 
    seg.push_back("0111111"); // 7
    seg.push_back("1111111"); // 8
    seg.push_back("1101111"); // 9


  while(cin >> n){
    if(n < 0) return 0;
    
    for(int i=0; i<n; i++){
      cin >> s;
      if(count == 0){
	start = seg[s];
	for(int i=0; i<7; i++)
	  cout << start[i]-'0';
	cout << endl;
	count++;
	ago = s;
	continue;
      }
	a = seg[ago];
	b = seg[s];
      for(int j=0; j<7; j++){
	if(a[j] == b[j]) cout << 0;
	else cout << 1;
      }
      cout << endl;

      ago = s;
    }
    count=0;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

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

int main() {
  int N, n;
  
  while(cin >> n){
    if(n == -1) break;
    string now, after;
    
    for(int cs = 0 ; cs < n ; cs++){
      cin >> N;
      
      if(cs == 0){
	cout << num[N] << endl;
	now = num[N];
      }
      else{
	after = num[N];
	for(int i = 0 ; i < 7 ; i++){
	  if(now[i] == after[i]) cout << '0';
	  else cout << '1';
	}
	cout << endl;
	now = after;
      }
    }
  }
  return 0;
}

C++: #include <cstdio>

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

int main(){
	unsigned long long int lighta = 0x3f065b4f66, lightb = 0x6d7d277f6f;
	int n = 0;
	while(scanf("%d", &n), ~n){
		int prev_j = 0;
		for(int i=n;i;i--){
			int j;
			scanf("%d", &j);
			binarywrite(prev_j ^ (j<5?lighta>>(4-j)*8&0xff:lightb>>(9-j)*8&0xff));
			prev_j = (j<5?lighta>>(4-j)*8&0xff:lightb>>(9-j)*8&0xff);
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
using namespace std;
 
#define rep(i,x) for(int i=0;i<x;i++)
 
int main(){
	int bit[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(1){
		int n;
		scanf("%d",&n); if(n==-1)break;
 
		int a=10;
		rep(i,n){
			int b;
			scanf("%d",&b);
 
			rep(j,7){
				printf("%d",(bit[a][j]+bit[b][j])&1);
			}
			printf("\n");
			a=b;
		}
	}
}

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

string to_bit(char n) {
    string s;
    for(int i = 0; i < 7; i++) {
        s.push_back((n & (1 << i)) ? '1' : '0');
    }
    return s;
}

int main() {
    for(int N; cin >> N, N != -1; ) {
        char state = 0;
        char numbers[] = {
            0b01111110,
            0b00110000,
            0b01101101,
            0b01111001,
            0b00110011,
            0b01011011,
            0b01011111,
            0b01110010,
            0b01111111,
            0b01111011
        };
        while(N--) {
            int T; cin >> T;
            string ans = "NA";
            for(char i = 0; i < (1 << 7); i++) {
                if((state ^ i) == numbers[T]) {
                    ans = to_bit(i);
                    state ^= i;
                    break;
                }
            }
            cout << ans << endl;
        }

    }
}

C++: #include <iostream>
#include <vector>
#include <bitset>

using namespace std;

vector<unsigned int> table { 63, 6, 91, 79, 102, 109, 125, 39, 127, 111 };

void solve(int from, int to)
{
	unsigned int b0	= 0;
	if( from != -1 ) {
		b0 = table[from];
	} 
	unsigned int b1 = table[to];
	cout << static_cast<bitset<7>>( b0 ^ b1 ) << endl;
}

int main(int argc, char* argv[])
{
	int num, d;
	vector<int> ds;

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

		for( int i = 0; i < num; i++ ) {
			cin >> d;
			ds.push_back(d);
		}
		int v0 = -1;
		for( auto  v1 : ds ) {
			solve(v0, v1);
			v0 = v1;
		}
		ds.clear();		
	}

    return 0;
}

C++: #include <cstdio>

int main()
{
	while(true) {

		int n, a[100];
		int mask[10];
		mask[0] = 1+2+4+8+16+32   ;
		mask[1] =   2+4           ;
		mask[2] = 1+2+  8+16+   64;
		mask[3] = 1+2+4+8+      64;
		mask[4] =   2+4+     32+64;
		mask[5] = 1+  4+8+   32+64;
		mask[6] = 1+  4+8+16+32+64;
		mask[7] = 1+2+4+     32   ;
		mask[8] = 1+2+4+8+16+32+64;
		mask[9] = 1+2+4+8+   32+64;

		scanf("%d", &n);
		if(n == -1)
			break;
		for(int i = 0; i < n; ++i) {
			scanf("%d", a + i);
		}

		int state = 0;
		
		for(int i = 0; i < n; ++i) {

			int sig = state ^ mask[a[i]];
			for(int bit = 6; bit >= 0; --bit)
				printf("%c", sig & (1 << bit) ? '1' : '0');
			printf("\n");
			state = mask[a[i]];
			
		}

	}

	return 0;
}

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

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

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

int main() {
    int n;
    while(cin >> n, n != -1) {
        bitset<7> s[10] = {0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110, 0b1101101, 0b1111101, 0b0100111, 0b1111111, 0b1101111};
        bitset<7> now(0);
        for(int i=0; i<n; ++i) {
            int d;
            cin >> d;
            cout << (now ^ s[d]) << endl;
            now = s[d];
        }
    }
}

C++: //22
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n,n!=-1;){
    int lcd[7]={};
    while(n--){
      int nm;
      cin>>nm;
      for(int i=6;i>=0;i--){
	static const int on[][7]={{1,1,1,1,1,1,0},{0,1,1,0,0,0,0},{1,1,0,1,1,0,1},{1,1,1,1,0,0,1},{0,1,1,0,0,1,1},{1,0,1,1,0,1,1},{1,0,1,1,1,1,1},{1,1,1,0,0,1,0},{1,1,1,1,1,1,1},{1,1,1,1,0,1,1}};
	cout<<(lcd[i]^on[nm][i]);
	lcd[i]=on[nm][i];
      }
      cout<<endl;
    }
  }
  return 0;
}