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

int main(){

  int b[11] = {63,6,91,79,102,109,125,39,127,111,0};
  int now = 11;
  int k;
  int n;
  int p;

  while(cin >> n){
    if(n == -1) break;
    
    for(int i=0;i<n;i++){
      cin >> k;
      if(i) p = (b[now]^b[k]);
      else p = b[k];
      for(int i=6;i>-1;i--) printf("%d", (p>>i)&1);
      printf( "\n" );
      now = k;
    }
  }

}

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;
    for(int i=0;i<n;i++){
      cin >> s;
      string a;
      if(i==0){
	cout << san[i] << endl;
	mem = san[i];
      }
      else{
	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<bits/stdc++.h>

using namespace std;

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


int main() {
	int n, d;
	string now;

	while (cin >> n, n != -1) {
		now = "0000000";
		for (int i = 0; i < n; ++i) {
			cin >> d;
			//cout << d << endl;
			for (int i = 0; i < 7; ++i) {
				cout << (now[i]^Display[d][i]);
			}
			cout << endl;
			now = Display[d];
		}
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main (){
  int  d[10][7] ={{0,1,1,1,1,1,1},
                 {0,0,0,1,1,0,0},
                 {1,1,1,0,1,1,0},
                 {1,0,1,1,1,1,0},
                 {1,0,0,1,1,0,1},
                 {1,0,1,1,0,1,1},
		 {1,1,1,1,0,1,1},
		 {0,0,0,1,1,1,1},
		 {1,1,1,1,1,1,1},
		 {1,0,1,1,1,1,1}};

  int n;
  while(cin>>n && n!=-1){
    int  s[7] = {0,0,0,0,0,0,0};
    for(int i=0;i<n;i++){
      int a;
      cin >>a;
      for(int j=0;j<7;j++){
	if(s[j]!=d[a][j]){
	  cout<<1;
	  s[j]=d[a][j];
	}
	else cout <<0;
      }
      cout <<endl;
    }
  }
  return 0;
}

C++: #include <stdio.h>
#pragma warning(disable : 4996)
int n, a[101];
const char c[11][8] = { "0000000", "0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111" };
int main() {
	a[0] = -1;
	while (true) {
		scanf("%d", &n);
		if (n == -1) break;
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			for (int j = 0; j < 7; j++) {
				if (c[a[i - 1] + 1][j] != c[a[i] + 1][j]) {
					printf("1");
				}
				else {
					printf("0");
				}
			}
			printf("\n");
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
long long fib(int n){
    //if(n==0) return 0;
    //if(n==1) return 1;
    //return fib(n-1) + fib(n-2);
    double pl = 1+sqrt(5),mi = 1-sqrt(5);
    double l = 1,r = 1;
    REP(i,n) l*=pl/2,r*=mi/2;
    l -= r;
    //l /= 1LL<<1;
    l /= sqrt(5);
    ull res = l;
    return res;
}
int main(){
  int n;
  vector<bitset<7>> seg(10);
  seg[0] = 0b0111111;
  seg[1] = 0b0000110;
  seg[2] = 0b1011011;
  seg[3] = 0b1001111;
  seg[4] = 0b1100110;
  seg[5] = 0b1101101;
  seg[6] = 0b1111101;
  seg[7] = 0b0100111;
  seg[8] = 0b1111111;
  seg[9] = 0b1101111;
  while(cin>>n,n!=-1){
    bitset<7> now;
    REP(i,n){
      int d;
      cin >> d;
      cout << (seg[d]^now) << endl;
      now = seg[d];
    }
  }
}

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

int light[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}
};

main(){
  int n;
  while(cin >> n,n!=-1){
    int s;
    int seg[7]={0};
    for(int i=0;i<n;i++){
      cin >> s;
      for(int j=0;j<7;j++){
	if(seg[j]==light[s][j]) cout << "0";
	else cout << "1";
      }
      cout << endl;
      for(int j=0;j<7;j++){
	seg[j]=light[s][j];
      }
    }
  }
}

C++: #include <iostream>
#include <bitset>
using namespace std;
int s[10] = {63,6,91,79,102,109,125,39,127,111};
int main() {
	int n, m;
	while (cin >> n, 0 <= n) {
		bitset<7> b(0);
        while (n--) {
			cin >> m;
			cout << (b^=s[m]) << endl;
			b = s[m];
		}
	}
}

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

using namespace std;

int main() {
    int n,i,j,k=0,temp;
    int pair[11]={
            0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,0b1101101,0b1111101,0b0100111,0b1111111,0b1101111,0b0000000
    };
    vector<int> xtemp;
    vector<vector<int>> x(0,vector<int>());
    do{

        vector<int> xtemp;
        xtemp.push_back(10);
        cin>>j;
        if(j==-1)break;
        for(i=0;i<j;i++){
            cin>>temp;
            xtemp.push_back(temp);
        }
        x.push_back(xtemp);
    }while(temp!=-1);
    for(j=0;j<x.size();j++) {
        for (i = 1; i < x[j].size(); i++) {
            cout << bitset<7>((pair[(unsigned int)x[j][i]]^pair[(unsigned int)x[j][i-1]])) << endl;
        }
    }

   // std::cout << "Hello, World!" << std::endl;
    return 0;
}