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 <algorithm>
constexpr int DISPLAY[] = { 0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110, 0b1101101, 0b1111101, 0b0100111, 0b1111111, 0b1101111 };
void show(int n) {
	for (int i = 6; i >= 0; --i) {
		std::cout << ((((1 << i) & n) == 0) ? 0 : 1);
	}
	std::cout << std::endl;
}
int main() {
	int n;
	int prev_state, d;
	std::cin >> n;
	while (n != -1) {
		prev_state = 0;
		for (auto i = 0; i < n; ++i) {
			std::cin >> d;
			prev_state ^= DISPLAY[d];
			show(prev_state);
		}
		std::cin >> n;
	}

}

C++: #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

//			0		  1			2		  3			4		  5			6		  7			8		  9			初期
VS str = { "0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111","0000000" };

string re(string a, string b) {
	string ret;
	rep(i, 7) {
		ret += a[i] == b[i] ? '0' : '1';
	}
	return ret;
}


int main() {
	while (true) {
		int n; cin >> n;
		if (n == -1)break;

		VI d(n + 1); d[0] = 10;
		rep(i, n)cin >> d[i + 1];
		FOR(i, 1, n + 1) {
			//cout << d[i - 1] << ", " << d[i] << " -> ";
			Cout(re(str[d[i - 1]], str[d[i]]));
		}
	}
}

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<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

string str[] = { "0111111","0000110","10111011","1001111","1100110",
				"1101101","1111101","01001111","1111111", "1101111" };

int main()
{
	int n;
	while (1) 
	{
		string s = "";
		cin >> n;
		if (n == -1)break;

		rep(i, n) {
			int num; cin >> num;
			if (i == 0) 
				cout << str[num] << endl;
			else {
				string tmp = "";
				rep(i, 7) {
					if (str[num][i] != s[i])
						tmp += "1";
					else
						tmp += "0";
				}
				cout << tmp << endl;
			}
			s = str[num];
		}
	}
	return 0;
}

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

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

int main(){
  int n;
  while(cin >> n, n>=0){
    string cur = "0000000";

    for(int i=0;i<n;i++){
      int a; cin >> a;
      string nxt = dig[a];

      for(int j=0;j<7;j++){
	if(cur[j] == nxt[j])cout << "0";
	else cout << "1";
      }
      cout << endl;

      cur = nxt;
    }
  }
}

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

using namespace std;

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

int in;

string now,ans;

void solve(){
	ans.clear();
	for(int i=0; i<7; i++){
		if(now[i] != seg[in][i])
			ans += '1';
		else
			ans += '0';
	}
	ans += '\0';
	now = seg[in];
}

int main(){
	int n;
	while(true){
		cin >> n;
		if(n == -1)
			return 0;
		for(int i=0; i<n; i++){
			cin >> in;
			if(i==0){
				now = seg[in];
				cout << now << endl;
				continue;
			}
			solve();
			cout << ans << endl;
		}
	}
}

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

int main() {
	vector<int> seg = {0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,0b1101101,0b1111101,0b0100111,0b1111111,0b1101111,0b0000000};
	while(1){
		int n;
		cin >> n;
		if(n==-1) break;
		int d0=10, d1;
		for(int i=0; i<n; i++){
			cin >> d1;
			cout << bitset<7>(seg[d0]^seg[d1]) << endl;
			d0=d1;
		}
	}

}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;
int n, m;
vector<int> vege;

const int INF = 1 << 29;

int main(void)
{
	//0111111 0000110 1011011 1001111 1100110 1101101 1111101 0100111 1111111 1101111
	int memo[] = {127 - 64, 6, 64 + 16 + 8 + 2 + 1, 64 + 15, 64 + 32 +4 + 2,64+32+8+4+1,127-2, 32+7,127,127-16 };
	int nisin[] = {64, 32, 16, 8, 4, 2, 1};
	while(cin >> n && n != -1)
	{
		int bit = 0;
		for (int i = 0; i < n; i++)
		{
			int a;
			cin >> a;
			int ans = bit ^ memo[a];
			bit = memo[a];
			for (int j = 0; j < 7; j++)
			{
				if(ans > nisin[j])
				{
					ans -= nisin[j];
					cout << 1;
				}
				else cout << 0;
			}
			cout << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int X[11][7];
int Xor(int i,int j){
	if(i==j)return 0;
	return 1;
}
int main()
{
	X[0][0]=0;X[0][1]=1;X[0][2]=1;X[0][3]=1;X[0][4]=1;X[0][5]=1;X[0][6]=1;
	X[1][0]=0;X[1][1]=0;X[1][2]=0;X[1][3]=0;X[1][4]=1;X[1][5]=1;X[1][6]=0;
	X[2][0]=1;X[2][1]=0;X[2][2]=1;X[2][3]=1;X[2][4]=0;X[2][5]=1;X[2][6]=1;
	X[3][0]=1;X[3][1]=0;X[3][2]=0;X[3][3]=1;X[3][4]=1;X[3][5]=1;X[3][6]=1;
	X[4][0]=1;X[4][1]=1;X[4][2]=0;X[4][3]=0;X[4][4]=1;X[4][5]=1;X[4][6]=0;
	X[5][0]=1;X[5][1]=1;X[5][2]=0;X[5][3]=1;X[5][4]=1;X[5][5]=0;X[5][6]=1;
	X[6][0]=1;X[6][1]=1;X[6][2]=1;X[6][3]=1;X[6][4]=1;X[6][5]=0;X[6][6]=1;
	X[7][0]=0;X[7][1]=1;X[7][2]=0;X[7][3]=0;X[7][4]=1;X[7][5]=1;X[7][6]=1;
	X[8][0]=1;X[8][1]=1;X[8][2]=1;X[8][3]=1;X[8][4]=1;X[8][5]=1;X[8][6]=1;
	X[9][0]=1;X[9][1]=1;X[9][2]=0;X[9][3]=1;X[9][4]=1;X[9][5]=1;X[9][6]=1;
	while(true){
		int N;
		int P[101];
		scanf("%d",&N);
		if(N==-1)break;
		P[0]=10;
		for(int i=1;i<=N;i++)scanf("%d",&P[i]);
		for(int i=0;i<N;i++){
			for(int j=0;j<7;j++){
				if(Xor(X[P[i]][j],X[P[i+1]][j]))printf("1");
				else printf("0");
			}
			printf("\n");
		}
	}
	return 0;
}