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>
using namespace std;

int main(void){
	int n = 0,in;
	int array[][8] ={
		{0,1,1,1,1,1,1}, // 0
		{0,0,0,0,1,1,0},
		{1,0,1,1,0,1,1},
		{1,0,0,1,1,1,1}, // 3
		{1,1,0,0,1,1,0}, // 4
		{1,1,0,1,1,0,1}, // 5
		{1,1,1,1,1,0,1}, // 6
		{0,1,0,0,1,1,1}, // 7
		{1,1,1,1,1,1,1}, // 8
		{1,1,0,1,1,1,1}  // 9
	};
	int box[] = {0,0,0,0,0,0,0};
	while(cin>>n,n!=-1){

		int box[] = {0,0,0,0,0,0,0};
		while(n--){
			cin>>in;
			for(int i = 0 ; i < 7 ; i ++){
				cout<<(box[i] != array[in][i]?1:0);
				box[i] = array[in][i];
			}
			cout<<endl;
		}
	}
}

C++: #include<iostream>

using namespace std;

int main(){

  int data[7], n;

  while(1){

    cin >> n;

    if(n == -1) break;
  
    for(int i = 0; i < 7; i++) data[i] = 0;

      
    for(int i = 0; i < n; i++){
      int num, indata[7];
      cin >> num;
      if(num == 0){
	indata[0] = 0;
	indata[1] = 1;
	indata[2] = 1;
	indata[3] = 1;
	indata[4] = 1;
	indata[5] = 1;
	indata[6] = 1;
      }else if(num == 1){
	indata[0] = 0;
	indata[1] = 0;
	indata[2] = 0;
	indata[3] = 0;
	indata[4] = 1;
	indata[5] = 1;
	indata[6] = 0;
      }else if(num == 2){
	indata[0] = 1;
	indata[1] = 0;
	indata[2] = 1;
	indata[3] = 1;
	indata[4] = 0;
	indata[5] = 1;
	indata[6] = 1;
      }else if(num == 3){
	indata[0] = 1;
	indata[1] = 0;
	indata[2] = 0;
	indata[3] = 1;
	indata[4] = 1;
	indata[5] = 1;
	indata[6] = 1;
      }else if(num == 4){
	indata[0] = 1;
	indata[1] = 1;
	indata[2] = 0;
	indata[3] = 0;
	indata[4] = 1;
	indata[5] = 1;
	indata[6] = 0;
      }else if(num == 5){
	indata[0] = 1;
	indata[1] = 1;
	indata[2] = 0;
	indata[3] = 1;
	indata[4] = 1;
	indata[5] = 0;
	indata[6] = 1;
      }else if(num == 6){
	indata[0] = 1;
	indata[1] = 1;
	indata[2] = 1;
	indata[3] = 1;
	indata[4] = 1;
	indata[5] = 0;
	indata[6] = 1;
      }else if(num == 7){
	indata[0] = 0;
	indata[1] = 1;
	indata[2] = 0;
	indata[3] = 0;
	indata[4] = 1;
	indata[5] = 1;
	indata[6] = 1;
      }else if(num == 8){
	indata[0] = 1;
	indata[1] = 1;
	indata[2] = 1;
	indata[3] = 1;
	indata[4] = 1;
	indata[5] = 1;
	indata[6] = 1;
      }else if(num == 9){
	indata[0] = 1;
	indata[1] = 1;
	indata[2] = 0;
	indata[3] = 1;
	indata[4] = 1;
	indata[5] = 1;
	indata[6] = 1;
      }

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

	  if(data[j] == 0) data[j] = 1;
	  else data[j] = 0;
	}
      }
      cout << endl;
    }
  }

  return 0;

}

C++: #include <stdio.h>

#define MAX 20000
#define MYSCAN scanf

int main(void){
	int n, m;
	int i, j;
	int nowseg[7];
	int seg[10][7] = {
			{ 0, 1, 1, 1, 1, 1, 1 },
			{ 0, 0, 0, 0, 1, 1, 1 },
			{ 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 (true){
		MYSCAN("%d", &n);
		if (n == -1){	break;	}
		for (i = 0; i < 7; i++){	nowseg[i] = 0;	}

		for (i = 0; i < n; i++){
			MYSCAN("%d", &m);
			for (j = 0; j < 7; j++){
				if (seg[m][j] == nowseg[j]){
					printf("0");					
				}
				else{
					printf("1");
				}
				nowseg[j] = seg[m][j];
			}
			printf("\n");
		}
	}

	return 0;

}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
using namespace std;
int main(){
    int latte[]={
        0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,
        0b1101101,0b1111101,0b0100111,0b1111111,0b1101111,
    };

    int n;
    while(cin>>n,n!=-1){
        int l=0;
        while(n--){
            int cafe;
            cin>>cafe;
            int p=l^latte[cafe];
            l=latte[cafe];
            for(int i=6;i>=0;i--){
                cout<<((p>>i)&1);
            }
            cout<<endl;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,x;
	string t[]={"0111111","0000110","1011011","1001111",
		"1100110","1101101","1111101","0100111","1111111","1101111"};
	while(cin>>n,n!=-1){
		string now="0000000";
		while(n--){
			cin>>x;
		string pre=t[x];
		for(int i=0;i<7;i++)
		if(pre[i]!=now[i])
		cout<<1;
		else cout<<0;
		cout<<endl;
		now=pre;
		}
		
	}
	return 0;
}

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

using namespace std;

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

int in,now;

string ans;

void solve(){
	ans.clear();
	for(int i=0; i<7; i++){
		if(seg[now][i] != seg[in][i])
			ans += '1';
		else
			ans += '0';
	}
	now = 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 = in;
				cout << seg[now] << endl;
				continue;
			}
			solve();
			cout << ans << endl;
		}
	}
}

C++: using namespace std;
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

typedef vector<int> VI;
typedef pair<int, int> PII;

#define REP(i, n) for(int i=0; i<n; i++)

int SEG[10] = {
	0x01111110,
	0x00110000,
	0x01101101,
	0x01111001,
	0x00110011,
	0x01011011,
	0x01011111,
	0x01110010,
	0x01111111,
	0x01111011
};

int t, n;
int d = 0;

void solve(int n)
{
	int s = SEG[n];
	REP(i, 7)
	{
		if((s&1) ^ (d&1)) cout << "1";
		else cout << "0";
		s >>= 4;
		d >>= 4;
	}
	cout << endl;
	d = SEG[n];
}

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

		d = 0;
		REP(i, t)
		{
			cin >> n;
			solve(n);
		}
	}
}

C++: #include <iostream>
using namespace std;
char tbl[] = {
  0x3f, 0x6, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x27, 0x7f, 0x6f,
};
int main()
{
  for(;;){
    int n;
    cin >> n;
    if(n < 0) break;
    int ans = 0;
    for(int i=0; i<n; i++){
      int j;
      cin >> j;
      ans ^= tbl[j];
      for(int k=0; k<7; k++){
        if((ans & (0x40 >> k)) == (0x40 >> k)) cout << 1;
        else cout << 0;
      }
      cout << endl;
      ans = tbl[j];
    }
  }
  return 0;
}

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

int main(){
    int N;
    while(cin >> N, N != -1){
        string now = "0000000";
        for(int i = 0; i < N; i++){
            int k;
            cin >> k;
            string S;
            if(k == 0) S = "0111111";
            if(k == 1) S = "0000110";
            if(k == 2) S = "1011011";
            if(k == 3) S = "1001111";
            if(k == 4) S = "1100110";
            if(k == 5) S = "1101101";
            if(k == 6) S = "1111101";
            if(k == 7) S = "0100111";
            if(k == 8) S = "1111111";
            if(k == 9) S = "1101111";

            string ans = "0000000";
            for(int i = 0;i < ans.size(); i++){
                if(now[i] != S[i]) ans[i] = '1';
            }
            now = S;
            cout << ans << endl;
        }
    }
    
}