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<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int bit[]={0x1111110,0x0110000,0x1101101,0x1111001,0x0110011,0x1011011,0x1011111,0x1110010,0x1111111,0x1111011,0};

int main() {
	int n;
	while(cin>>n,n!=-1){
		int b,i,pr=10,nw;
		for(i=0;i<n;i++){
			cin>>nw;
			b=bit[pr]^bit[nw];
			pr=nw;
			int j;
			for(j=0;j<7;j++){cout<<(b&1);b/=16;}
			cout<<endl;
		}
	}
	return 0;
}

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

int main(){
	string segments[11] = {"0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111", "0000000"};
	int num;
	int nowSegment;
	int input;

	while(cin >> num, num != -1){
		nowSegment = 10;
		for(int i=0; i < num; i++){
			cin >> input;
			for(int j=0; j < 7; j++){
				if(segments[nowSegment][j] == segments[input][j]) cout << 0;
				else cout << 1;
			}
			cout << endl;
			nowSegment = input;
		}
	}
}

C++: #include <stdio.h>
int signal(int *da,int set){
	if(set==1){
		if(*da==0){
			*da=1;
			return 1;
		}
		else{
			*da=1;
			return 0;
		}
	}
	else {
		if(*da==0){
			*da=0;
			return 0;
		}
		else{
			*da=0;
			return 1;
		}
	}
}

class seg{
public:
	int a,b,c,d,e,f,g;
	int da,db,dc,dd,de,df,dg;
	void empty();
	void set(int num);
	void Set(int num);
};
void seg::empty(){
  /*switch(num){
  case 0:
	  a=b=c=d=e=f=1;
	  g=0;
	  break;
  case 1:
	  b=c=1;
	  a=d=e=f=g=0;
	  break;
  case 2:
	  a=b=d=e=g=1;
	  c=f=0;
	  break;
  case 3:
	  a=b=c=d=g=1;
	  f=e=0;
	  break;
  case 4:
	  b=c=f=g=1;
	  a=e=d=0;
	  break;
  case 5:
	  a=c=d=f=g=1;
	  b=e=0;
	  break;
  case 6:
	  a=c=d=e=f=g=1;
	  b=0;
  case 7:
	  a=b=c=f=1;
	  e=d=g=0;
	  break;
  case 8:
	  a=b=c=d=e=f=g=1;
	  break;
  case 9:
	  a=b=c=d=f=g=1;
	  e=0;
	  break;
  }*/
	a=b=c=d=e=f=g=0;
	da=a;db=b;dc=c;dd=d;de=e;df=f;dg=g;
	//printf("%d%d%d%d%d%d%d%d\n",g,f,e,d,c,b,a);
}

void seg::set(int num){
	switch(num){
	case 0:
		a = signal(&da,1);
		b = signal(&db,1);
		c = signal(&dc,1);
		d = signal(&dd,1);
		e = signal(&de,1);
		f = signal(&df,1);
		g = signal(&dg,0);
		break;
	case 1:
		a = signal(&da,0);
		b = signal(&db,1);
		c = signal(&dc,1);
		d = signal(&dd,0);
		e = signal(&de,0);
		f = signal(&df,0);
		g = signal(&dg,0);
		break;
	case 2:
		a = signal(&da,1);
		b = signal(&db,1);
		c = signal(&dc,0);
		d = signal(&dd,1);
		e = signal(&de,1);
		f = signal(&df,0);
		g = signal(&dg,1);
		break;
	case 3:
		a = signal(&da,1);
		b = signal(&db,1);
		c = signal(&dc,1);
		d = signal(&dd,1);
		e = signal(&de,0);
		f = signal(&df,0);
		g = signal(&dg,1);
		break;
	case 4:
		a = signal(&da,0);
		b = signal(&db,1);
		c = signal(&dc,1);
		d = signal(&dd,0);
		e = signal(&de,0);
		f = signal(&df,1);
		g = signal(&dg,1);
		break;
	case 5:
		a = signal(&da,1);
		b = signal(&db,0);
		c = signal(&dc,1);
		d = signal(&dd,1);
		e = signal(&de,0);
		f = signal(&df,1);
		g = signal(&dg,1);
		break;
	case 6:
		a = signal(&da,1);
		b = signal(&db,0);
		c = signal(&dc,1);
		d = signal(&dd,1);
		e = signal(&de,1);
		f = signal(&df,1);
		g = signal(&dg,1);
		break;
	case 7:
		a = signal(&da,1);
		b = signal(&db,1);
		c = signal(&dc,1);
		d = signal(&dd,0);
		e = signal(&de,0);
		f = signal(&df,1);
		g = signal(&dg,0);
		break;
	case 8:
		a = signal(&da,1);
		b = signal(&db,1);
		c = signal(&dc,1);
		d = signal(&dd,1);
		e = signal(&de,1);
		f = signal(&df,1);
		g = signal(&dg,1);
		break;
	case 9:
		a = signal(&da,1);
		b = signal(&db,1);
		c = signal(&dc,1);
		d = signal(&dd,1);
		e = signal(&de,0);
		f = signal(&df,1);
		g = signal(&dg,1);
		break;
	}
	printf("%d%d%d%d%d%d%d\n",g,f,e,d,c,b,a);
}

	
int main(){
	int num,n;
	seg seg;
	seg.empty();
	scanf("%d",&n);
	while(n!=-1){
		while(n--){
			scanf("%d",&num);
			seg.set(num);
		}
		seg.empty();
		scanf("%d",&n);
	}
	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;
 
 
 
}

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n;
    string num[]={
        "0111111",
        "0000110",
        "1011011",
        "1001111",
        "1100110",
        "1101101",
        "1111101",
        "010011",
        "111111",
        "1101111"
    };
    
    while(cin>>n){
        if(n==-1)break;
        
        string now="0000000";
        
        rep(i,n){
            int a;
            cin>>a;
            rep(i,7){
                if(now[i]!=num[a][i])cout<<"1";
                else cout<<"0";
            }
            cout<<endl;
            now=num[a];

        }
        
    }
    return 0;
}