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"
#include "math.h"

#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;

/** Problem0228 : Seven Segments **/
int main()
{
	string list[10];
	list[0] = "0111111";
	list[1] = "0000110";
	list[2] = "1011011";
	list[3] = "1001111";
	list[4] = "1100110";
	list[5] = "1101101";
	list[6] = "1111101";
	list[7] = "0100111";
	list[8] = "1111111";
	list[9] = "1101111";
	int n, in;

	while (cin >> n, n>0) {
		string now="0000000";
		rep(k, n) {
			cin >> in;
			string signal;
			rep(i, 7) {
				if (list[in][i] != now[i])
					signal+='1';
				else
					signal+='0';
			}
			now = list[in];
			cout << signal << endl;
		}
	}
	return 0;
}

C++: #include <cstdio>

int main()
{
	while(true) {

		int n, a[100];
		int mask[10];
		mask[0] = 1+2+4+8+16+32;
		mask[1] = 2+4;
		mask[2] = 1+2+8+16+64;
		mask[3] = 1+2+8+16+64;
		mask[4] = 2+4+32+64;
		mask[5] = 1+4+8+32+64;
		mask[6] = 1+4+8+16+32+64;
		mask[7] = 1+2+4+32;
		mask[8] = 1+2+4+8+16+32+64;
		mask[9] = 1+2+4+8+32+64;

		scanf("%d", &n);
		if(n == -1)
			break;
		for(int i = 0; i < n; ++i) {
			scanf("%d", a + i);
		}

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

			int sig = state ^ mask[a[i]];
			for(int bit = 6; bit >= 0; --bit)
				printf("%c", sig & (1 << bit) ? '1' : '0');
			printf("\n");
			state = mask[a[i]];
			
		}

	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

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

  bool bi[10][7];
  REP(i,10)
    REP(j,7) 
      bi[i][j] = (s[i][j] == '1');
  while(cin >>n, n!=-1) {
    int a;
    bool prev[7] = {};
    REP(i,n) {
      cin >> a;
      REP(i,7) {
        cout << (bi[a][i] xor prev[i]);
        prev[i] = bi[a][i];
      }
      cout << endl;
    }
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())

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

int main(void){
  int n;
  while(cin>>n,n+1){
    vector<int> num(n);
    REP(i,n)cin>>num[i];
    REP(i,n){
      if(i==0)cout<<seg[num[i]]<<endl;
      else{
        string out;
        REP(j,7){
          if(seg[num[i]][j]!=seg[num[i-1]][j])out+="1";
          else out+="0";
        }
        cout<<out<<endl;
      }
    }
  }

  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, 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 (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++: #include <stdio.h>
#include <iostream>

using namespace std;

void t(int a[],int b[],int c[]) {
	for (int i = 0; i < 7; i++) {
		if (a[i] != c[i]) {
			a[i] = c[i];
			b[i] = 1;
		} else {
			b[i] = 0;
		}
	}
	return;
}

int main() {
	int a[7] = {0};
	int k,n;

	while (1) {
		int b[7] = {0};
		cin >> n;
		if (n == -1) {
			break;
		} else {
			for (int j = 0; j < n; j++) {
				cin >> k;
					if (k == 0) {
						int c[] = {1,1,1,1,1,1,0};
						t(a,b,c);
					} else if (k == 1) {
						int c[] = {0,1,1,0,0,0,0};
						t(a,b,c);
					} else if (k == 2) {
						int c[] = {1,1,0,1,1,0,1};
						t(a,b,c);
					} else if (k == 3) {
						int c[] = {1,1,1,1,0,0,1};
						t(a,b,c);
					} else if (k == 4) {
						int c[] = {0,1,1,0,0,1,1};
						t(a,b,c);
					} else if (k == 5) {
						int c[] = {1,0,1,1,0,1,1};
						t(a,b,c);
					} else if (k == 6) {
						int c[] = {1,0,1,1,1,1,1};
						t(a,b,c);
					} else if (k == 7) {
						int c[] = {1,1,1,0,0,1,0};
						t(a,b,c);
					} else if (k == 8) {
						int c[] = {1,1,1,1,1,1,1};
						t(a,b,c);
					} else {
						int c[] = {1,1,1,1,0,1,1};
						t(a,b,c);
					}
				
					for (int i = 6; i >= 0; i--) {
						cout << b[i];
					}
					cout << endl;
			}
		}
	}

	return 0;
}

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

int main() {

  int g,f,e,d,c,b,a;

  string num[10] ;
  num[0] = "0111111";
  num[1] = "0000110";
  num[2] = "1011011";
  num[3] = "1001111";
  num[4] = "1100110";
  num[5] = "1101101";
  num[6] = "1111101";
  num[7] = "0100111";
  num[8] = "1111111";
  num[9] = "1101111";

  string ima,mae;
  mae.resize(7);
  ima.resize(7);


  int qu;
  while(1) {
  cin >> qu;
  if(qu == -1) break;
  for(int i=0;i<7;i++) ima[i] = '0';
  int n = 0;
  for(int j=0;j<qu;j++) {
    cin >> n;
    

    for(int i=0;i<7;i++) {
      if(num[n][i] != ima[i]) ima[i] = '1';
      else ima[i] = '0';
    }
   
    for(int i=0;i<7;i++) cout << ima[i];
    cout << endl;
    ima = num[n];
  }
  }
  return 0;



}