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<vector>
#include<string>
using namespace std;

int main(){
  vector<string> seg;
  int n, s, count=0, ago;
  string a,b;

    seg.push_back("0111111"); // 0
    seg.push_back("0000110"); // 1
    seg.push_back("1011011"); // 2
    seg.push_back("1001111"); // 3
    seg.push_back("1100110"); // 4 
    seg.push_back("1101101"); // 5 
    seg.push_back("1111101"); // 6 
    seg.push_back("0111111"); // 7
    seg.push_back("1111111"); // 8
    seg.push_back("1101111"); // 9


  while(cin >> n){
    if(n < 0) return 0;
    
    for(int i=0; i<n; i++){
      cin >> s;
      if(count == 0){
	cout << seg[s] << endl;
	count++;
	ago = s;
	continue;
      }
	a = seg[ago];
	b = seg[s];
      for(int j=0; j<7; j++){
	if(a[j] == b[j]) cout << 0;
	else cout << 1;
      }
      cout << endl;

      ago = s;
    }
    count=0;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n;
  string s[10];
  s[0] = "0111111";
  s[1] = "0000110";
  s[2] = "1011011";
  s[3] = "1001111";
  s[4] = "1100110";
  s[5] = "1101101";
  s[6] = "1111101";
  s[7] = "0100111";
  s[8] = "1111111";
  s[9] = "1101111";

  bool bi[9][7];
  REP(i,9)
    REP(j,7) 
      bi[i][j] = (s[i][j] == '1');
  while(cin >>n, n!=-1) {
    int a;
    bool prev[7] = {};
    REP(i,n) {
      cin >> a;
      REP(i,7) {
        cout << (bi[a][i] xor prev[i]);
        prev[i] = bi[a][i];
      }
      cout << endl;
    }
  }
}

C++: #include <iostream>
using namespace std;
const char* bits[] = {
	"0111111",
	"0000110",
	"1011011",
	"1001111",
	"1100110",
	"1101101",
	"1111101",
	"0100111",
	"1111111",
	"1101111",
};

int main () {
	int n;
	while (cin >> n, n != -1) {
		char current[] = "0000000";
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			for (int i = 0; i < 7; i++) {
				if (current[i] != bits[x][i]) {
					cout << '1';
					current[i] = bits[x][i];
				}
				else {
					cout << '0';
				}
			}
			cout << endl;
		}
	}
	return 0;
}

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

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

int disp[10] = {
0b1111110, 
0b0110000, 
0b1101101, 
0b1111001, 
0b0110011,
0b1011011, 
0b1011111, 
0b1110010, 
0b1111111, 
0b1111011,};

int main(){
	while(true){
		int n;
		cin>>n;
		if(n==-1) break;
		
		int state = 0;
		REP(i, n){
			int x;
			cin>>x;
			int a = disp[x];
			int c = state ^ a;
			REP(i, 7) printf("%d", (c>>i)%2);
			printf("\n");
			state = a;
		}
	}
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    string num[] = {"0111111", "0000110", "1011011", "1001111", "1100110",
                    "1101101", "1111101", "0100111", "1111111", "1101111"};

    for(;;){
        int n;
        cin >> n;
        if(n == -1)
            return 0;

        bitset<7> bs(0);
        for(int i=0; i<n; ++i){
            int a;
            cin >> a;
            cout << (bs ^ bitset<7>(num[a])).to_string() << endl;
            bs = bitset<7>(num[a]);
        }
    }
}

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){
		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()
{

while(1)
{
int n,num;
string sig="0000000",str;
cin>>n;
if(n==-1)break;
for(int k=0;k<n;k++)
{
cin>>num;
string ans="";

if(num==0)str="0111111";
else if(num==1)str="0000110";
else if(num==2)str="1011011";
else if(num==3)str="1001111";
else if(num==4)str="1100110";
else if(num==5)str="1101101";
else if(num==6)str="1111101";
else if(num==7)str="0100111";
else if(num==8)str="1111111";
else str="1101111";
for(int i=0;i<7;i++)
{
if(sig.at(i)!=str.at(i))ans+='1';
else ans+='0';
}
sig=str;
cout<<ans<<endl;
}
}
return 0;
}

C++: #include <cstdio>
#include <iostream>
using namespace std;
string sig[11]={
"0111111",
"0000110",
"1011011",
"1001111",
"1100110",
"1101101",
"1111101",
"0100111",
"1111111",
"1101111"
};
string now;
int main() {
    int n;
    while (scanf("%d",&n)) {
        if (n==-1) break;
        now="0000000";
        for (int i=0; i<n; i++) {
            int s; scanf("%d",&s);
            string res="";
            for (int j=0; j<7; j++) {
                if (now[j]==sig[s][j]) res+='0';
                else res+='1';
            }
            cout<<res<<endl;
            now=sig[s];
        }
    }
}

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

int main()
{
  int n,m,i,display;
  vector<int> v(10);
  v[0] = 63;
  v[1] = 6;
  v[2] = 91;
  v[3] = 79;
  v[4] = 102;
  v[5] = 109;
  v[6] = 125;
  v[7] = 39;
  v[8] = 127;
  v[9] = 111;
  while(cin>>n,~n){
    display=0;
    while(n-->0){
      cin>>m;
      display^=v[m];
      for(i=1<<6;i>0;i=i>>1) cout<<((display&i)!=0);
      display=v[m];
      cout<<endl;
    }
  }
}

C++: #include <iostream>
#include <string>
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;
				}
		}
	}
}