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>
int main(){
	int table[10][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}};
	int a;
	while(scanf("%d",&a),~a){
		int first[]={0,0,0,0,0,0,0};
		for(int i=0;i<a;i++){
			int b;
			scanf("%d",&b);
			for(int j=6;j>=0;j--){
				printf("%d",first[j]^table[b][j]);
				first[j]=table[b][j];
			}
			printf("\n");
		}
	}
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

std::string to_binString(unsigned int val)
{
  std::string str = "";
  while( val != 0 ) {
    if( (val & 1) == 0 )
      str.insert(str.begin(), '0');
    else
      str.insert(str.begin(), '1');
    val >>= 1;
  }
  while(str.size()<7){
    str = "0" + str;
  }
  return str;
}

const int bit[10] = {126,48,109,121,51,91,111,127,123};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
//   rep(i,11){
//     cout << to_binString(bit[i])<<endl;
//   }
  ll n;
  while(cin >> n && n != -1){
    ll a;
    int state = 0;
    rep(i,n){
      cin >> a;
      auto s = to_binString(state ^ bit[a]);
      reverse(all(s));
      cout << s <<endl;
      state = bit[a];
    }
  }
  return 0;
}

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

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

int main(){
    while(1){
        int n;
        cin >> n;
        if(n == -1) break;
        
        int now[7] = {};
        
        while(n-- > 0){
            int next;
            cin >> next;
            for(int i = 0; i < 7; i++){
                cout << (now[i] ^ seg[next][i]);
                now[i] = seg[next][i];
            }
            cout << endl;
        }
        
    }
    
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

void printState( int val ) {
  for ( int i = 6; i >= 0; i-- ){
	if ( val & ( 1 << i ) ) {
	  cout << 1;
	} else {
	  cout << 0;
	}
  }
  cout << endl;
}

int main() {

  array<int, 10> table = {{
	  0b111111, 0b110, 0b1011011, 0b1001111, 0b1100110,
	  0b1101101, 0b1111101, 0b100111, 0b1111111, 0b1101111
	}};
  
  while ( true ){
	int n;
	cin >> n;
	if ( n <= 0 ) break;
	
	int state = 0;
	for ( int i = 0; i < n; i++ ) {
	  int nval;
	  cin >> nval;
	  printState( state ^ table[ nval ] );
	  state = table[ nval ];
	}	
  }
}

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

int main()
{
	const int seg[] = {0x3f, 0x6, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x27, 0x7f, 0x6f};
	int n;
	
	while (cin >> n, n != -1){
		int res = 0;
		int num;
		for (int i = 0; i < n; i++){
			cin >> num;
			cout << bitset<7>(res^seg[num]) << endl;
			res = seg[num];
		}
	}
	return (0);
}

C++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <P,P> PP;
typedef pair <int,PP> PPP;

static const double eps = 1e-8;

static const string numbers[] = {"1111110","0110000","1101101","1111001","0110011",
	"1011011","1011111","1110010","1111111","1111011"};
static const int order[] = {'g'-'a','f'-'a','e'-'a','d'-'a','c'-'a','b'-'a','a'-'a'};

string changeOrder(string numbers){
	reverse(numbers.begin(),numbers.end());
	return numbers;
}

void setStage(bitset<7>& stage,bitset<7>& next){
	for(int i=0;i<7;i++){
		if(next[i] & 1){
			stage[i] = ~stage[i];
		}
	}
}

int main(){

	int n;	
	while(~scanf("%d",&n)){
		if(n==-1) break;
		bitset<7> next;
		bitset<7> stage;
		for(int i=0;i<n;i++){
			int light;
			scanf("%d",&light);
			bitset<7> num(changeOrder(numbers[light]));
			next = stage ^ num;	
			setStage(stage,next);
			printf("%s\n",next.to_string().c_str());
			
		}
	}
}

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

using namespace std;

int main(){


	int nums[10];
	nums[0]=63;
	nums[1]=6;
	nums[2]=91;
	nums[3]=79;
	nums[4]=102;
	nums[5]=109;
	nums[6]=125;
	nums[7]=39;
	nums[8]=127;
	nums[9]=111;

	int n;
	while(cin>>n&&n!=-1){
		int s=0;
		for(int j = 0; j < n; j++){
			int t;
			cin>>t;
			int ret=nums[t]^s;
			for(int i = 6; i >= 0; i--){
				if((ret>>i)&1){
					cout<<1;
				}
				else
					cout<<0;
			}
			cout<<endl;
			s=nums[t];
		}
	}

	return 0;
}

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

int dis[10] = { 63,6,91,79,102,109,125,39,127,111 };
int main()
{
	for (int i = 0; i < 10; i++) {
		for (int k = 64; k != 0; k >>= 1) {
			if (dis[i]&k)cout << 1;
			else cout << 0;
		}
		cout << endl;
	}
	int a;
	while (cin >> a, a != -1) {
		int now = 0;
		for (int b = 0; b < a; b++) {
			int c;
			cin >> c;
			int d = now^dis[c];
			for (int k = 64; k != 0; k >>= 1) {
				if (d&k)cout << 1;
				else cout << 0;
			}
			cout << endl;
			now = dis[c];
		}
	}
}