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

int main() {
	int n;
	string sgmt[10] = {
		"0111111",
		"0000110",
		"1011011",
		"1001111",
		"1100110",
		"1101101",
		"1111101",
		"0100111",
		"1111111",
		"1101111"
	};

	while (cin >> n) {
		if (n == -1)break;
		string s = "0000000";

		for (int x = 0;x < n;x++) {
			int a;
			cin >> a;

			string ans;

			for (int i = 0;i < 7;i++) {
				if (s[i] != sgmt[a][i])ans.push_back('1');
				else ans.push_back('0');
				s[i] = sgmt[a][i];
			}

			cout << ans << endl;
		}

	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	//gfedcba1101101
	int n;
	bool  table[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}};
	while(cin>>n,n!=-1){
		bool now[7]={0,0,0,0,0,0,};
		for(int i=0;i<n;i++){
			int tmp;
			cin>>tmp;
			for(int i=0;i<7;i++){
				if(now[i]==table[tmp][i])cout<<0;
				else cout<<1;
				if(i==6)cout<<endl;
				else cout<<" ";
			}
			for(int i=0;i<7;i++)now[i]=table[tmp][i];
		}
	}
	return 0;
}

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,105,121,51,91,114,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];
//       cout << a << ":" + to_binString(state) <<endl;
    }
  }
  return 0;
}

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

int nikara (const string &sig);
void tenkara ( int );

int main () {
	string sig[10] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","1111111","1101111"};
	string before,hoge;
	int n,num;
	int var = 0x0001;
	int bvar,piyo;
	
	while ( cin >> n, n != -1 ){
		bvar = 0;
		for ( int i = 0; i < n; i++ ) {
			cin >> num;
			hoge = sig[num];
			
			var = nikara ( hoge );
			piyo = var ^ bvar;
			tenkara ( piyo );
			
			bvar = var;
		}
	}
}

int nikara (const string &sig) {
	int out = 0;
	for (int i = 0, size = sig.size(); i < size ; ++i ) {
		out *= 2;
		out += ((int)sig[i] == 49) ? 1 : 0;
	}
	return out;
}

void tenkara (int hoge) {
	string sig;
	for ( int i = 0; i < 7; i++ ) {
		sig[i] = hoge % 2 + '0';
		hoge = hoge / 2;
	}
	
	for ( int i = 6; i >= 0; i-- ) {
		cout << sig[i];
	}
	cout << endl;
}

C++: // 0228.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include "stdafx.h"

#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
int main()
{
	ios::sync_with_stdio(false);
	string a[10];
	a[0] = "0111111";
	a[1] = "0000110";
	a[2] = "1011011";
	a[3] = "1001111";
	a[4] = "1100001";
	a[5] = "1101101";
	a[7] = "0100111";
	a[6] = "1111101";
	a[8] = "1111111";
	a[9] = "1101111";
	while (true) {

		ll n;
		cin >> n;
		if (n == -1) { break; }
		string  s = "0000000";
		for (int i = 0; i < n; i++) {
			int d;
			cin >> d;
			for (int j = 0; j < 7; j++) {
				if (a[d][j] == s[j]) { cout << 0; }
				else { cout << 1; }
			}
			cout << endl;
			s = a[i];
		}
	
	}
	
	return 0;
}

C++: #include <stdio.h>

#define MAX 20000
#define MYSCAN scanf

int main(void){
	int n, m;
	int i, j;
	int nowseg[7];
	int seg[10][7] = {
			{ 0, 1, 1, 1, 1, 1, 1 },
			{ 0, 0, 0, 0, 1, 1, 1 },
			{ 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 },
			{ 1, 1, 1, 1, 1, 1, 1 },
			{ 1, 1, 0, 1, 1, 1, 1 } };

	while (true){
		MYSCAN("%d", &n);
		if (n == -1){	break;	}
		for (i = 0; i < 7; i++){	nowseg[i] = 0;	}

		for (i = 0; i < n; i++){
			MYSCAN("%d", &m);
			for (j = 0; j < 7; j++){
				if (seg[m][j] == nowseg[j]){
					printf("0");					
				}
				else{
					printf("1");
				}
				nowseg[j] = seg[m][j];
			}
			printf("\n");
		}
	}

	return 0;

}

C++: // 2011/07/27 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int seg[11][7] = {{0,1,1,1,1,1,1},	// eÌf[^
	                  {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}};	// seg[10]Íñ\¦

	while(true){
		int n;
		cin >> n;
		if(n==-1)
			break;

		int lst = 10;		// ¼OÌiúlÍñ\¦j
		int now;		// »ÝÌ
		for(int i=0; i<n; i++){
			cin >> now;
			for(int j=0; j<7; j++)
				cout << (seg[lst][j]+seg[now][j])%2;	// r¼I_a
			cout << endl;
			lst = now;
		}
	}

	return 0;
}