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++: // This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <vector>
#include <bitset>
using namespace std;
int main()
{
    vector<int> seg  {0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,0b1101101,0b1111101,0b0100111,0b1111111,0b1101111};
      int n;
    while(true){
        cin>>n;
        if(n==-1){
        break;
        }
    vector<int> vec(n);
    for(int i=0;i<n;i++){
    cin>>vec.at(i);
    }
    cout<<bitset<7>(seg.at(vec.at(0)))<<endl;
   for(int i=1;i<n;i++){
       cout<<bitset<7>(seg.at(vec.at(i))^seg.at(vec.at(i-1)))<<endl;
   }
    }
    
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/

C++: #include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};

int main(){
    string str[10] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
    while(1){
        int n;
        scanf("%d",&n);
        if(n==-1)break;
        string cur = "0000000";
        for(int i=0;i<n;i++){
            int next;
            scanf("%d",&next);
            string ans = "0000000";
            for(int i=0;i<8;i++){
                if(cur[i]!=str[next][i]){
                    ans[i] = '1';
                }
            }
            cout << ans << endl;
            cur = str[next];
        }
    }

    return 0;
}

C++: #include <stdio.h>
int n, a[101];
const char c[11][8] = { "0000000", "0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111" };
int main() {
	a[0] = -1;
	while (true) {
		scanf("%d", &n);
		if (n == 0) break;
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			for (int j = 0; j < 7; j++) {
				if (c[a[i - 1] + 1][j] != c[a[i] + 1][j]) {
					printf("1");
				}
				else {
					printf("0");
				}
			}
			printf("\n");
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
  vector<string> vs;
  vs.push_back("1111110");

  vs.push_back("0110000");
  vs.push_back("1101101");
  vs.push_back("1111001");
  vs.push_back("0110011");
  vs.push_back("1011011");

  vs.push_back("1011111");
  vs.push_back("1110010");
  vs.push_back("1111111");
  vs.push_back("1111011");

  while(true){
    int n;
    scanf("%d", &n);
    if(n==-1)break;
    string state = "0000000";
    for(int i = 0; i < n; ++i){
      int d;
      scanf("%d", &d);
      string signal;
      for(int j = 0; j < 7; ++j){
	if(state[j]!=vs[d][j]){
	  signal += '1';
	}else{
	  signal += '0';
	}
      }
      reverse(signal.begin(),signal.end());
      printf("%s\n", signal.c_str());
      state = vs[d];
    }

  }
  
  return 0;
}

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

int main()
{
	int n;
	const char v[10][8] = { "0111111", "0000110", "1011011", "1001111", "1100110", 
							"1101101", "1111101", "0100111", "1111111", "1101111" };

	cin >> n;

	while (n > 0) {
		int d;
		cin >> d;
		cout << v[d] << endl;
		int dp = d;

		for (int i = 1; i < n; i++) {
			cin >> d;
			for (int j = 0; j < 7; j++) {
				if (v[d][j] == v[dp][j])
					cout << 0;
				else
					cout << 1;
			}
			cout << endl;
			dp = d;
		}

		cin >> n;
	}

	return 0;
}

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

using namespace std;
int main(void){
  int n;
  int d[10][7] = {
    {1,1,1,1,1,1,0}, // 0
    {0,1,1,0,0,0,0}, // 1
    {1,1,0,1,1,0,1}, // 2 
    {1,1,1,1,0,0,1}, // 3
    {0,1,1,0,0,1,1}, // 4
    {1,0,1,1,0,1,1}, // 5
    {1,0,1,1,1,1,1}, // 6
    {1,1,1,0,0,1,0}, // 7
    {1,1,1,1,1,1,1}, // 8
    {1,1,1,1,0,1,1}  // 9
  };
  while(cin>>n,n>=0){
    int l[7] = {0};
    while(n--){
      int num;
      cin>>num;
      for(int i = 6 ; i >= 0 ; i --){
	cout<<(l[i]==d[num][i]?0:1);
	l[i]=d[num][i];
      }
      cout<<endl;
    }
  }
}

C++: #include <iostream>
#include <string>
using namespace std;
string segment(int i){
	if(i==0)
	return "0111111";
	if(i==1)
	return "0000110";
	if(i==2)
	return "1011011";
	if(i==3)
	return "1001111";
	if(i==4)
	return "1100110";
	if(i==5)
	return "1101101";
	if(i==6)
	return "1111101";
	if(i==7)
	return "0100111";
	if(i==8)
	return "1111111";
	if(i==9)
	return "1101111";
}
int main() {
	// your code goes here
	
	int n,m;
	while(cin >> n && n!=0){
	string now="0000000",next;
		for(int i=0;i<n;i++){
			cin >> m;
			next=segment(m);
			for(int j=0;j<7;j++)
			if(now[j]!=next[j])
			cout << 1;
			else
			cout << 0;
			cout << endl;
			now=next;
		}
	}
	return 0;
}

C++: // 2011/01/09 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int 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}};

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

		int pst = 10;
		int now;
		for(int i=0; i<n; i++){
			cin >> now;
			for(int j=0; j<7; j++)
				cout << (seg[pst][j]+seg[now][j])%2;
			cout << endl;
			pst = now;
		}
	}

	return 0;
}

C++: #include <iostream>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.sevensegment", "r", stdin );

	const string num[] = { 
		"0111111", "0000110", "1011011", "1001111",
		"1100110", "1101101", "1111101", "0100111",
		"1111111", "1101111"
	};
	int n, m;

	while (1){
		string prev (7, '0');
		string curr (7, '0');
		cin >> n;
		if (n == -1){
			break;
		} // end if

		for (int i = 0; i < n; ++i){
			cin >> m;
			for (int j = 0; j < 7; ++j){
				curr[j] = ((num[m][j] - '0') ^ (prev[j] - '0')) + '0'; 
			} // end for
			cout << curr << endl;
			prev = num[m];
		} // end for
	} // end while
		
	return 0;
}