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>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007


string calc(int n){
	string ret("0000000");
	rep(i,7){
		ret[i]=n%2+'0';
		n/=2;
	}
	reverse(all(ret));
	return ret;
}



int main(){
	int v[11]={63,6,91,79,102,109,125,39,127,111,0};
	int a=10,b,c;
	int n;
	while(cin>>n && n>0){
		a=10;
		rep(i,n){
			cin>>b;
			c=(v[a]^v[b]);
			cout<<calc(c)<<endl;
			a=b;
		}
	}
}

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

using namespace std;

string solve(string a, string b){
  string res="";
  for(int i=0;i<a.size();i++){
    if(a[i]==b[i])res+='0';
    else res+='1';
  }
  return res;
}

int main(void){

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


  string a,b;
  while(cin >> n,~n){

    cin >> x;
    cout << s[x] << endl;
    a = s[x];
    n--; 

    while(n--){
      cin >> x;
      b=s[x];
      string ans=solve(a,b);
      cout << ans << endl;
      a=b;
    }
  }

  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

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

int main() {
	int n;
	while (cin >> n, n != -1) {
		string now = "0000000";
		
		REP(t, n) {
			int num; scanf("%d", &num);
			
			REP(i, 7) {
				putchar(now[i] != b[num][i] ? '1' : '0');
				now[i] = b[num][i];
			}
			puts("");
		}
	}
	return 0;
}

C++: #include <iostream>
#include <bitset>
using namespace std;
#define NONE  0b0000000
#define ZERO  0b0111111
#define ONE   0b0000110
#define TWO   0b1011011
#define THREE 0b1001111
#define FOUR  0b1100110
#define FIVE  0b1101101
#define SIX   0b1111101
#define SEVEN 0b0100111
#define EIGHT 0b1111111
#define NINE  0b1101111

int main(void)
{
  while (true)
  {
    int n;
    cin >> n;
    if ( n == -1 ) break;
    int display = NONE;
    for (int i = 0; i < n; ++i)
    {
      int num;
      cin >> num;
      int buf;
      switch(num)
      {
        case 0:
          buf = ZERO;
          break;
        case 1:
          buf = ONE;
          break;
        case 2:
          buf = TWO;
          break;
        case 3:
          buf = THREE;
          break;
        case 4:
          buf = FOUR;
          break;
        case 5:
          buf = FIVE;
          break;
        case 6:
          buf = SIX;
          break;
        case 7:
          buf = SEVEN;
          break;
        case 8:
          buf = EIGHT;
          break;
        case 9:
          buf = NINE;
          break;
      }
    cout << bitset<7>(buf xor display) << endl;
    display = buf;
    }
  }
  return 0;
}

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

const string numbers[10] = {
    "0111111",
    "1101011",
    "1011011",
    "1001111",
    "1100110",
    "1101101",
    "1111101",
    "0100111",
    "1111111",
    "1101111"
};

string convert( int k, string prev )
{
    string answer;
    for ( int i = 0; i < 8; i++ ) {
        if ( numbers[k][i] == prev[i] ) {
            answer += '0';
        } else {
            answer += '1';
        }
    }
    return answer;
}

int main( void )
{
    int n;
    while ( cin >> n && n != -1 ) {
        string prev = "000000";
        for ( int i = 0; i < n; i++ ) {
            int k;
            cin >> k;
            cout << convert( k, prev ) << endl;
            prev = numbers[k];
        }
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int data[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(1){
    int n,no,set[7]={0};
    cin >> n;
    if(n==-1)break;
    while(n--){
      cin >> no;
      for(int i=0,flg=0;i<7;i++,flg=0){
	if(!data[no][i]&&set[i]==1)set[i]--,flg=1;
	if(data[no][i]&&set[i]==0)set[i]++,flg=1;
	cout << (flg?1:0);
      }
      cout << endl;
    }
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pi;
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair

int n;

main(){
	while(cin>>n){
		if(n==-1)break;
		
		switch(n){
			case 0:puts("1111110");break;
			case 1:puts("0110000");break;
			case 2:puts("1101101");break;
			case 3:puts("1111001");break;
			case 4:puts("0110011");break;
			case 5:puts("1011011");break;
			case 6:puts("1011111");break;
			case 7:puts("1110010");break;
			case 8:puts("1111111");break;
			case 9:puts("1111011");break;
		}
	}
}

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

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

string convert( int k, string prev )
{
    string answer;
    for ( int i = 0; i < 7; i++ ) {
        if ( numbers[k][i] == prev[i] ) {
            answer += '0';
        } else {
            answer += '1';
        }
    }
    return answer;
}

int main( void )
{
    int n;
    while ( cin >> n && n != -1 ) {
        string prev = "0000000";
        for ( int i = 0; i < n; i++ ) {
            int k;
            cin >> k;
            cout << convert( k, prev ) << endl;
            prev = numbers[k];
        }
    }
    return 0;
}