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 <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 k,n;

	while (1) {
		int a[7] = {0};
		int b[7];
		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<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); 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()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

const char *disp[10] = {
  "1111110",
  "0110000",
  "1101101",
  "1111001",
  "0110011",
  "1011011",
  "1011111",
  "1110010",
  "1111111",
  "1111011",
};

char myxor(char a, char b){
  return (a != b)  ? '1' : '0';
}

int main(){
  int n;
  while(scanf("%d", &n), n != -1){
    char b[7]; REP(i,7) b[i] = '0';
    REP(i,n){
      int t;
      scanf("%d", &t);
      REP(j,7){
        putchar(myxor(b[6-j], disp[t][6-j]));
        b[6-j] = disp[t][6-j];
      }
      puts("");
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> segments = {0b0111111, 0b0000110, 0b1011011, 0b1001111,
                          0b1100110, 0b1101101, 0b1111101, 0b0100111,
                          0b1111111, 0b1101111};

  while(1) {
    int n;
    cin >> n;
    if(n == -1) { break; }
    int bef, aft;
    cin >> bef;
    cout << bitset<7>(segments[bef]) << endl;
    for(int i = 0; i < n - 1; i++) {
      cin >> aft;
      cout << bitset<7>(segments[bef] ^ segments[aft]) << endl;
      bef = aft;
    }
  }
  return 0;
}

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

int main(){
  bool seg[11][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},
		    {0,0,0,0,0,0,0} };
  int n,prv,tmp;

  while(1){
    cin >> n;
    if(n<0)break;

    prv = 10;
    for(int i=0;i<n;i++){
      cin >> tmp;
      for(int j=0;j<7;j++){
	if(seg[prv][j] == seg[tmp][j])cout << 0;
	else cout << 1;
      }
      cout << endl;
      prv = tmp;
    }
  }
}

C++: #include<iostream>
#include<string>
using namespace std;
int main() {
	string date[11],now;
	date[0] = "1111110";
	date[1] = "0110000";
	date[2] = "0110000";
	date[3] = "1111001";
	date[4] = "0110011";
	date[5] = "1011011";
	date[6] = "1011111";
	date[7] = "1110010";
	date[8] = "1111111";
	date[9] = "1111011";
	int n,kazu[111];
	while (1) {
		now = "0000000";
		cin >> n;
		if (n == -1) goto a;
		for (int i = 1; i <= n; i++) {
			cin >> kazu[i];
		}
		for (int i = 1; i <= n; i++) {
			for(int z=6;z>=0;z--){
				if (date[kazu[i]][z] == now[z]) {
					cout << 0;
				}
				else {
					cout << 1;
					if (now[z] == '0') {
						now[z] = '1';
					}
					else {
						now[z] = '0';
					}
				}
			}
			cout << endl;
		}
	}
a:;
}

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

int main()
{
	int n;
	string num[] = {
		"0111111",
		"0000110",
		"1011011",
		"1001111",
		"1100110",
		"1101101",
		"1111101",
		"0100111",
		"1111111",
		"1101111"
	};
	
	while (scanf("%d", &n), n != -1){
		int input;
		char str[10] = "0000000";
		char diff[10] = "0000000";
			
		for (int i = 0; i < n; i++){
			
			scanf("%d", &input);
			
			for (int j = 0; j < 7; j++){
				if (input == 0){
					
					//printf(" %s %s\n", str, num[0].c_str());
					
					if (str[j] == num[0][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[0][j];
					}
				}
				else if (input == 1){
				//	printf(" %s\n", str);
					
					if (str[j] == num[1][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[1][j];
					}
				}
				else if (input == 2){
					if (str[j] == num[2][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[2][j];
					}
				}
				else if (input == 3){
					if (str[j] == num[3][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[3][j];
					}
				}
				else if (input == 4){
					if (str[j] == num[4][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[4][j];
					}
				}
				else if (input == 5){
					if (str[j] == num[5][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[5][j];
					}
				}
				else if (input == 6){
					if (str[j] == num[6][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[6][j];
					}
				}
				else if (input == 7){
					if (str[j] == num[7][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[7][j];
					}
				}
				else if (input == 8){
					if (str[j] == num[8][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[8][j];
					}
				}
				else if (input == 9){
					if (str[j] == num[9][j]){
						diff[j] = '0';
					}
					else {
						diff[j] = '1';
						str[j] = num[9][j];
					}
				}
			}
			printf("%s\n", diff);
		}
	}
}

C++: #include<iostream>
using namespace std;
string c[10]={
	"0111111",
	"0000110",
	"1011011",
	"1001111",
	"1100110",
	"1101101",
	"1111101",
	"0100111",
	"1111111",
	"1101111"
};
int n;
main()
{
	while(cin>>n,n>=0)
	{
		string s="0000000";
		for(;n--;)
		{
			int d;cin>>d;
			for(int j=0;j<7;j++)
			{
				cout<<(s[j]!=c[d][j]);
				s[j]=c[d][j];
			}
			cout<<endl;
		}
	}
}