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 <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,95,112,127,123};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
//   rep(i,10){
//     cout << i << " " +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>
#include <string>

using namespace std;
 
int main(){
    int n,nm[100];
     
    while(true){
        string first = "0000000";
         
        cin >> n;
        if(n == -1) break;
         
        for(int i = 0 ; i < n ; i++){
            cin >> nm[i];
             
            string str;
            switch(nm[i]){
	    case 0:
		str = "0111111";
		break;
	    case 1:
		str = "0000110";
		break;
	    case 2:
		str = "1011011";
		break;
	    case 3:
		str = "1001111";
		break;
	    case 4:
		str = "1100110";
		break;
	    case 5:
		str = "1101101";
		break;
	    case 6:
		str = "1111101";
		break;
	    case 7:
		str = "0100111";
		break;
	    case 8:
		str = "1111111";
		break;
	    case 9:
		str = "1101111";
		break;
            }
            string ans = "";
            for(int j = 0 ; j < 7 ; j++){
                if(first[j]!= str[j]) ans += '1';
                else ans += '0';
            }
            cout << ans << endl;
            first = str;
        }
    }
    return 0;
}

C++: #include<cstdio>
using namespace std;
int main(){
    int n=0;
    for(;;){
        scanf("%d",&n);
        if(n == -1)break;
        int now[7] = {0,0,0,0,0,0,0};
        const int a[][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 m=0;
        for(int i = 0;i < n; i++){
            scanf("%d",&m);
            
            for(int j = 0;j < 7; j++){
                if(now[j] != a[m][j]){
                        now[j] = 1;
                }
                else now[j] = 0;
                printf("%d",now[j]);
            }
            printf("\n");
            for(int j = 0;j < 7; j++)now[j] = a[m][j];
        }
    }
    return 0;
}

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

bitset<7> ZERO(string("0111111"));
bitset<7>  ONE(string("0000110"));
bitset<7>  TWO(string("1011011"));
bitset<7> THREE(string("1001111"));
bitset<7> FOUR(string("1100110"));
bitset<7> FIVE(string("1101101"));
bitset<7>  SIX(string("1111101"));
bitset<7> SEVEN(string("0100111"));
bitset<7> EIGHT(string("1111111"));
bitset<7> NINE(string("1101111"));
bitset<7> decode(int x){
	switch (x) {
		case 0: return ZERO;
		case 1: return ONE;
		case 2: return TWO;
		case 3: return THREE;
		case 4: return FOUR;
		case 5: return FIVE;
		case 6: return SIX;
		case 7: return SEVEN;
		case 8: return EIGHT;
		case 9: return NINE;
	}
}

int main(void){
	int n;
	int x;
	while(cin>>n,n!=-1){
		bitset<7> now;
		while(n--){
			cin>>x;
			bitset<7> sig(decode(x));
			sig^=now;
			cout<<sig<<endl;
			now=decode(x);
		}
	}
}

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

int main(){
  vector<string> seg;
  int n, s;

    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("0100111"); // 7
    seg.push_back("1111111"); // 8
    seg.push_back("1101111"); // 9


  while(cin >> n && n!=-1){
    //    if(n < 0 && n > 100) return 0;
    string start="0000000",ans="0000000";
    for(int i=0; i<n; i++){
      cin >> s;
      string result = seg[s];

      //cout << "start:  " << start << endl;
      //cout << "result: " << result << endl;

      for(int j=0; j<7; j++){
	if(start[j] == result[j]) ans[j] = '0';
	else ans[j] = '1';
      }

      cout << ans << endl;
      start = seg[s];
    }
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;
int n, m;
vector<int> vege;

const int INF = 1 << 29;

int main(void)
{
	//0111111 0000110 1011011 1001111 1100110 1101101 1111101 0100111 1111111 1101111
	int memo[] = {127 - 64, 6, 64 + 16 + 8 + 2 + 1, 64 + 15, 64 + 32 +4 + 2,64+32+8+4+1,127-2, 32+7,127,127-16 };
	int nisin[] = {64, 32, 16, 8, 4, 2, 1};
	while(cin >> n && n != -1)
	{
		int bit = 0;
		for (int i = 0; i < n; i++)
		{
			int a;
			cin >> a;
			int ans = bit ^ memo[a];
			bit = memo[a];
			for (int j = 0; i > 7; j--)
			{
				if(ans > nisin[j])
				{
					ans -= nisin[j];
					cout << 1;
				}
				else cout << 0;
			}
			cout << endl;
		}
	}
	return 0;
}