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 <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

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

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, num;
bool table[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 } };

int main(){
	while (cin >> n&&n != -1){
		bool a[7] = { 0, 0, 0, 0, 0, 0, 0 };
		REP(i, n){
			cin >> num;
			REP(j, 7){
				bool f = a[j] ^ table[num][j];
				cout << f;
				a[j] = table[num][j];
			}
			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(){
	int n;
	string num[]={"1111110",
	"0110000",
	"1101101",
	"1111001",
	"0110011",
	"1011011",
	"1011111",
	"1110010",
	"1111111",
	"1111011",
	"0000000",
	};
	
	while(cin>>n){
		if(n==-1)break;
		
		int zen=10;
		rep(i,n){
			int t;
			cin>>t;
			rep(j,7){
				cout<<!(num[t][6-j]==num[zen][6-j]);
			}
			cout<<endl;
			zen=t;
		}
	}
}

C++: #include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int a[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,11,1},{1,1,0,1,1,1,1}};
  int b[7],c[100],n;
  while(cin>>n&&n!=-1){
    for(i=0;i<n;i++)
      cin>>c[i];
    memset(b,0,sizeof(b));
    for(i=0;i<n;i++){
      for(j=0;j<7;j++){
	cout<<(b[j]^a[c[i]][j]);
	b[j]=(b[j]+(b[j]^a[c[i]][j]))%2;
      }
      cout<<endl;
    }
  }
  return 0;
}

C++: #include<stdio.h>
int pat[10][7];
void set(int n,int a,int b,int c,int d,int e,int f,int g){
	pat[n][0]=a;
	pat[n][1]=b;
	pat[n][2]=c;
	pat[n][3]=d;
	pat[n][4]=e;
	pat[n][5]=f;
	pat[n][6]=g;
}

int main(){
	while(1){
	int n,i;
	scanf("%d",&n);
		if(n==-1)return 0;
	set(0,1,1,1,1,1,1,0);
	set(1,0,1,1,0,0,0,0);
	set(2,1,1,0,1,1,0,1);
	set(3,1,1,1,1,0,0,1);
	set(4,0,1,1,0,0,1,1);
	set(5,1,0,1,1,0,1,1);
	set(6,1,0,1,1,1,1,1);
	set(7,1,1,1,0,0,1,0);
	set(8,1,1,1,1,1,1,1);
	set(9,1,1,1,1,0,1,1);
	int old,now;
	int j;
	scanf("%d",&old);
		for(i=6;i>=0;i--){
			if(pat[old][i]==1)printf("1");
			else printf("0");
		}
		printf("\n");
	for(i=0;i<n-1;i++){
		scanf("%d",&now);
		for(j=6;j>=0;j--){
			if(pat[old][j]!=pat[now][j])printf("1");
			else printf("0");
		}
		printf("\n");
		old=now;
	}
	}
}

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

int main()
{
	//gfedcba
	bool tpr[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}};
	bool now[7];
	int in,n;

	while(scanf("%d",&n) && n != -1){
		for(int i = 0; i < 7; i++)
			now[i] = false;
		for(int i = 0; i < n; i++){
			scanf("%d",&in);
			for(int j = 0; j < 7; j++){
				if(tpr[in][j] == now[j])
					printf("0");
				else{
					now[j] = tpr[in][j];
					printf("1");
				}
			}
			printf("\n");
		}
	}
	
	return 0;
}

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

int dis[10] = { 63,6,91,79,102,109,115,39,127,111 };
int main()
{
	int a;
	while (cin >> a, a != -1) {
		int now = 0;
		for (int b = 0; b < a; b++) {
			int c;
			cin >> c;
			int d = now^dis[c];
			for (int k = 64; k != 0; k >>= 1) {
				if (d&k)cout << 1;
				else cout << 0;
			}
			cout << endl;
			now = dis[c];
		}
	}
}

C++: #include <iostream>
using namespace std;
int main(){
	const string SEG[]={"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
	int n;
	while(cin>>n){
		if(n==-1)break;
		string current = "0000000";
		for(int i=0;i<n;++i){
			int num;
			cin>>num;
			for(int j=0;j<7;j++)cout<<(current[j]!=SEG[num][j])?"1":"0";
			current = SEG[num];
			cout<<"\n";
		}
	}
}

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

/*
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 a
1011 b
1100 c
1101 d
1110 e
1111 f
*/

const unsigned char BIT_DATA[10] = {
	0x3f,
	0x06,
	0x5b,
	0x4f,
	0x66,
	0x6d,
	0x7d,
	0x27,
	0x7f,
	0x6f
};

void showAsBinary(unsigned char num){
	for(int i = 0;i < 7;i++){
		if(num & (0x40 >> i)) cout << '1';
		else cout << '0';
	}
	cout << endl;
}

int main(){
	
	int n;
	while(1){
		cin >> n;
		if(n == -1) break;
		unsigned char data = 0;
		for(int i = 0;i < n;i++){
			int num;
			cin >> num;
			showAsBinary(data ^ BIT_DATA[num]);
			data = BIT_DATA[num];
		}
	}
	
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <bitset>

using namespace std;

vector<unsigned int> table { 63, 6, 91, 79, 102, 109, 125, 39, 127, 111 };

void solve(int from, int to)
{
	unsigned int b0 = table[from];
	unsigned int b1 = table[to];
	cout << static_cast<bitset<7>>( b0 ^ b1 ) << endl;
}

int main(int argc, char* argv[])
{
	int num, d;
	vector<int> ds;

	while(1) {
		cin >> num;
		if( num == -1 )
			break;

		for( int i = 0; i < num; i++ ) {
			cin >> d;
			ds.push_back(d);
		}
		int v0 = -1;
		for( auto  v1 : ds ) {
			solve(v0, v1);
			v0 = v1;
		}
		ds.clear();		
	}

    return 0;
}