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() {
  string signals[] = {
    "0111111",
    "0000110",
    "1011011",
    "1001111",
    "1100110",
    "1101101",
    "1111101",
    "0100111",
    "1111111",
    "1101111"
  };
  while (true) {
    int n, k;
    string cur(7, '0');
    cin >> n;
    if (n < 0) {
      return 0;
    }
    for (int i = 0; i < n; ++i) {
      cin >> k;
      for (int j = 0; j < 7; ++j) {
        cout << (cur[j] == signals[k][j]? '0': '1');
      }
      cout << endl;
      cur = signals[k];
    }
  }
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    char num[10][8] = {
        {"0111111"},
        {"0000110"},
        {"1011011"},
        {"1001111"},
        {"1100110"},
        {"1101101"},
        {"1111101"},
        {"0100111"},
        {"1111111"},
        {"1101111"}
    };
    while(cin >> n, n != -1){
        char display[8] = {"0000000"};
        while(n--){
            int inp;
            cin >> inp;
            rep(i,7){
                if(display[i] == num[inp][i]){
                    cout << '0';
                }else{
                    cout << '1';
                }
            }
            cout << endl;
            strcpy(display, num[inp]);
        }
    }
}

C++: using namespace std;

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


int main(void){
  int n;
  while(cin>>n, (n!=-1)){
    string now = "0000000";
    for(int i=0;i<n;i++){
      int x;
      cin>>x;
      string change = "0000000";
      for(int i=0;i<7;i++){
        if(s[x][i] != now[i]){
          change[i] = '1';
        }
      }
      cout<<change<<endl;
      now = s[x];
    }
  }

  return 0;
}

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

using namespace std;

int main() {
    int n, k;
    char out[10][8] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
    char bit[8];
    while (cin >> n, n != -1) {
          for (int i = 0; i < 7; ++i) bit[i] = '0';
          bit[7] = '\0';
          for (int i = 0; i < n; ++i) {
              cin >> k;
              for (int j = 0; j < 7; ++j) {
                  if (out[k][j] != bit[j]) {
                     cout << 1;
                     bit[j] = (bit[j] == '0' ? '1' : '0');
                  }
                  else cout << 0;
              }
              cout << endl;
          }
    }
    return 0;
}

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

int main() {
  int n;
  int num;
  string now, next;
  static string data[10] = {"0111111","0000110","1011011","1001111","1100110",
			    "1101101","1111101","0100111","1111111","1101111"};
  while(1) {
    cin >> n;
    if(n == -1) break;
    now = "0000000";
    for(int i = 0; i < n; i++) {
      cin >> num;
      for(int i = 0; i < 7; i++) {
	if(now[i] == data[num][i]) {
	  cout << "0";
	} else {
	  cout << "1";
	}
      }
      now = data[num];
      cout << endl;
    }
  }
  return 0;
}

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

int main(){
    while(1){    
        int n;
        cin >> n;
        if(n==-1) break;
        vector<int> seg(10,0);
        seg.at(0)=0b0111111;
        seg.at(1)=0b0000110;
        seg.at(2)=0b1011011;
        seg.at(3)=0b1001111;
        seg.at(4)=0b1100110;
        seg.at(5)=0b1101101;
        seg.at(6)=0b1111101;
        seg.at(7)=0b0100111;
        seg.at(8)=0b1111111;
        seg.at(9)=0b1101111;
        vector<int> data(n+1,0);
        vector<int> out(n,0);
        for(int i=0;i<n;i++){
            cin >> data.at(i+1);
            data.at(i+1)=seg.at(data.at(i+1));
        }
        for(int j=0;j<n;j++){
            out.at(j)=data.at(j)^data.at(j+1);
        cout << bitset<7>(out.at(j)) << endl;
        }
    }    
}

C++: #include <cstdio>

int zero[7] = {1,1,1,1,1,1,0};
int one[7] = {0,1,1,0,0,0,0};
int two[7] = {1,1,0,1,1,0,1};
int three[7] = {1,1,1,1,0,0,1};
int four[7] = {0,1,1,0,0,1,1};
int five[7] = {1,0,1,1,0,1,1};
int six[7] = {1,0,1,1,1,1,1};
int seven[7] = {1,1,1,0,0,1,0};
int eight[7] = {1,1,1,1,1,1,1};
int nine[7] = {1,1,1,1,0,1,1};

int main(){
	int n;
	while(scanf("%d",&n)){
		if(n == -1)break;
		int seg[7]={0,0,0,0,0,0,0};
		for(int i=0;i<n;++i){
			int a;
			scanf("%d",&a);
			if(a==0){
				for(int i=0;i<7;++i){
					if(zero[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=zero[6-i];
			}else if(a==1){
				for(int i=0;i<7;++i){
					if(one[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=one[6-i];
			}else if(a==2){
				for(int i=0;i<7;++i){
					if(two[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=two[6-i];
			}else if(a==3){
				for(int i=0;i<7;++i){
					if(three[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=three[6-i];
			}else if(a==4){
				for(int i=0;i<7;++i){
					if(four[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=four[6-i];
			}else if(a==5){
				for(int i=0;i<7;++i){
					if(five[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=five[6-i];
			}else if(a==6){
				for(int i=0;i<7;++i){
					if(six[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=six[6-i];
			}else if(a==7){
				for(int i=0;i<7;++i){
					if(seven[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=seven[6-i];
			}else if(a==8){
				for(int i=0;i<7;++i){
					if(eight[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=eight[6-i];
			}else if(a==9){
				for(int i=0;i<7;++i){
					if(nine[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=nine[6-i];
			}
			printf("\n");
		}
	}
}

C++: #include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
   int n,no;
   int item[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}};
   while(cin>>n){
       if(n==-1) break;
       int be[]={0,0,0,0,0,0,0};
       for(int i=0;i<n;i++){
          cin>>no;
          for(int j=0;j<7;j++){
              int tmp=be[j]^item[no][j];
              cout<<tmp;
              be[j]=item[no][j];
          }
          cout<<endl;
       }
   }
    return 0;
}