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>
using namespace std;
int main(){
  int n,s;
  string san[10];
  san[0]="0111111"; 
  san[1]="0000110";
  san[2]="1011011";
  san[3]="1001111";
  san[4]="1100110";
  san[5]="1011101";
  san[6]="1111101";
  san[7]="0100111";
  san[8]="1111111";
  san[9]="1101111";
  while(cin>>n){
    if(n==-1) break;
    string mem;
    for(int i=0;i<n;i++){
      cin >> s;
      if(i==0){
	cout << san[i] << endl;
	mem = san[i];
      }
      else{
	for(int i=0;i<7;i++){
	  if(san[s][i]==mem[i]) cout << '0';
	  else cout << '1';
	}
	cout << endl;
	mem = san[s];
      }
    }
  }
  return 0;
}

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

int num[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 main(){

  int n;
  while(1){
    cin >> n;
    if(n==-1) break;
    int pre =10,next;
    for(int i=0;i<n;i++){
      cin  >> next;
      for(int j=0;j<7;j++){
	if(num[pre][j] != num[next][j]) cout << "1";
	else cout << "0";
      }
      pre = next;
      cout << "\n";
    }

  }

}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	string table[] = { "0111111","0000110","1011011","1001111","1100110","1101101","1111101","1111111","1101111"};
	int n;
	while(cin >> n , ~n){
		string cur = "0000000";
		rep(i,n){
			int number; cin >> number;
			rep(i,7)cout << (cur[i] != table[number][i]);
			cout << endl;
			cur = table[number];
		}
	}
}

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<stdio.h>
int main(void)
{
	int seg[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 change[7];
	int n,a;
	int i,j;
	
	scanf("%d",&n);
	while(n!=-1){
		for(i=0;i<7;i++){	
			change[i]=0;
		}
		for(i=0;i<n;i++){
			scanf("%d",&a);
			for(j=0;j<7;j++){
				if(seg[a][j]==change[j]){
					printf("0");
				}
				else {
					printf("1");
				}
				change[j]=seg[a][j];
			}
			printf("\n");
		}
		scanf("%d",&n);
	}
	return 0;
}

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

void i_to_b(int n){
	for(int i=0 ; i<7 ; ++i, n <<= 1){
		cout << ((n & 64)? 1 : 0);
	}
	cout << endl;
}

int main(){
	int n;
	int f[10] = {63,6,91,79,102,109,125,39,127,111};
	while( cin >> n , ~n ){
		int state = 0;
		for(int i=0 ; i<n ; ++i ){
			int d;
			cin >> d;
			i_to_b( state ^ f[d] );
			state = f[d];
		}
	}
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	while(1){
		cin>>n;
		if(n==-1)break;
		for(int i=0 ; i<n ; i++ ){
			int x;
			cin>>x;
			switch(x){
				case 0:
					cout<<"0111111"<<endl;
					break;
				case 1:
					cout<<"0000110"<<endl;
					break;
				case 2:
					cout<<"1011011"<<endl;
					break;
				case 3:
					cout<<"1001111"<<endl;
				case 4:
					cout<<"1100110"<<endl;
					break;
				case 5:
					cout<<"1101101"<<endl;
					break;
				case 6:
					cout<<"1111101"<<endl;
					break;
				case 7:
					cout<<"0100111"<<endl;
					break;
				case 8:
					cout<<"1111111"<<endl;
					break;
				case 9:
					cout<<"1101111"<<endl;
					break;
				}
		}
	}
}

C++: #include<iostream>

using namespace std;

int main(){

	int n;
	int in;
	bool 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}};
	bool now[7];

	while(1){

		cin>>n;
		if(n==-1) break;

		for(int i=0;i<7;i++){
			now[i]=false;
		}

		for(int i=0;i<n;i++){
			cin>>in;
			for(int j=0;j<7;j++){
				if(now[j]!=data[in][j]) cout<<"1";
				else cout<<"0";
				now[j]=data[in][j];
			}
			cout<<endl;
		}

	}

}

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

using namespace std;

string hantei(int);

main(){
  int n, in;
  while(1){
    cin >> n;
    if(n==-1) break;
    string now="0000000";
    for(int i=0;i<n;i++){
      cin >> in;
      string tmp=hantei(in);
      string out="";
      for(int j=0;j<7;j++){
	if(now[j]==tmp[j]) out+='0';
	else{
	  out+='1';
	}
      }
      cout << out << endl;
      now=tmp;
    }
  }
  return 0;
}


string hantei(int n){
  if(n==0)
    return "0111111";
  if(n==1)
    return "0000110";
  if(n==2)
    return "1011011";
  if(n==3)
    return "1001111";
  if(n==4)
    return "1100110";
  if(n==5)
    return "1101101";
  if(n==6)
    return "1111101";
  if(n==7)
    return "0100111";
  if(n==8)
    return "1111111";
  if(n==9)
    return "1101111";
}

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

using namespace std;

bitset<7> segs[10];

void init() {
	segs[0] = bitset<7>(string("0111111"));
	segs[1] = bitset<7>(string("0000110"));
	segs[2] = bitset<7>(string("1011011"));
	segs[3] = bitset<7>(string("1001111"));
	segs[4] = bitset<7>(string("1100110"));
	segs[5] = bitset<7>(string("1101101"));
	segs[6] = bitset<7>(string("1111101"));
	segs[7] = bitset<7>(string("0100111"));
	segs[8] = bitset<7>(string("1111111"));
	segs[9] = bitset<7>(string("1101111"));
}

int main() {
	init();
	int n;
	while (cin >> n) {
		if (n == -1) break;
		bitset<7> cur((string)"0000000");
		for (int i = 0; i < n; i++) {
			int p; cin >> p;
			cout << (cur ^ segs[p]).to_string() << endl;
			cur = segs[p];
		}
	}
	return 0;
}