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;

    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 && 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;
      /*
      for(int i=0; i<7; i++)
	cout <<  ans[i]-'0';
      cout << endl;
      */
      start = seg[s];
    }

  }
}

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()
{
	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];
		}
	}
}

C++: // AOJ 0228
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string data[10];
	data[0] = "0111111";
	data[1] = "0000110";
	data[2] = "1011011";
	data[3] = "1001111";
	data[4] = "1100110";
	data[5] = "1101101";
	data[6] = "1111101";
	data[7] = "0100111";
	data[8] = "1111111";
	data[9] = "1101111";

	int n;
	while (cin >> n){
		if (n == -1) break;
		string str = "";
		int a;
		cin >> a; cout << data[a] << endl;
		str = data[a];
		for (int i = 0; i < n - 1; i++){
			cin >> a;
			string out;
			for (int j = 0; j < 7; j++){
				if (str[j] != data[a][j]) out += '1';
				else out += '0';
			}
			cout << out << endl;
			str = data[a];
		}
	}

	return 0;
}

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

using namespace std;

int main() {

  string num_str[11] = {
    
    "0111111",
    "0000110",
    "1011011",
    "1001111",
    "1100110",
    "1101101",
    "1111101",
    "0100111",
    "1111111",
    "1101111",
    "0000000"

  };

  int n;
  int num,num_prev;

  string signal;


  while(cin >> n) {

    if(n==-1) break;

    signal="0000000";
    num_prev=10;

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

      cin >> num;

      for(int j=0;j<7;j++) {

	signal[j]=((num_str[num_prev][j]-48)^(num_str[num][j]-48)+48);

      }

      num_prev=num;

      cout << signal << endl;

    }

  }

  return 0;

}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};

int num[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() {
  int n;

  while(cin >> n, n != -1) {
    int bnum;
    REP(i, n) {
      int nnum;
      cin >> nnum;
      if(i == 0) {
	REP(j, 7) cout << num[nnum][j];
      }
      else {
	REP(j, 7) {
	  if(num[nnum][j] != num[bnum][j]) cout << 1;
	  else cout << 0;
	}
      }
      cout << endl;
      bnum = nnum;
    }
  }
}

C++: #include<iostream>
#include<string>
using namespace std;
string bin(int n){
int i;
string s="       ";
for(i=0;i<7;i++){
if(n%2==0)s[6-i]='0';else s[6-i]='1';
n>>=1;
}
return s;
}
int main(){
int n,i,j,k,p[10]={63,6,91,79,102,109,125,39,127,111};
while(cin>>n){
if(n==-1)break;
for(i=0;i<n;i++){
k=j;cin>>j;
if(i>0)cout<<bin(p[j]^p[k])<<endl;
else cout<<bin(p[j])<<endl;
}
}
return 0;
}

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 <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, ~n) {
		bitset<7> b(0);
        while (n--) {
			cin >> m;
			cout << (b^=s[m]) << endl;
			b = s[m];
		}
	}
}

C++: #include<iostream>
using namespace std;
int x[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 p[7];
int main() {
	int n, a;
	while (true) {
		cin >> n; if (n == -1) { break; }
		for (int i = 0; i < 7; i++) { p[i] = 0; }
		for (int i = 0; i < n; i++) {
			cin >> a;
			for (int j = 0; j < 7; j++) {
				cout << (p[j] ^ x[a][j]);
				p[j] = x[a][j];
			}
			cout << endl;
		}
	}
}

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

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

  while( cin >> n, n != -1 ) {
    string now = "0000000";

    while( n-- ) {
      int num;
      string next = "0000000";

      cin >> num;
      for(int i=0; i<7; i++) {
	if( data[num][i] != now[i] ) next[i] = '1';
      }

      cout << next << endl;
      now = data[num];
    }
  }

  return 0;
}