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 <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int bit[11][7] = {
	{1,1,1,1,1,1,0},
	{0,1,1,0,0,0,0},
	{1,1,0,1,1,0,1},
	{1,1,1,1,0,0,1},
	{0,1,1,0,0,1,1},
	{1,0,1,1,0,1,1},
	{1,0,1,1,1,1,1},
	{1,1,1,0,0,1,0},
	{1,1,1,1,1,1,1},
	{1,1,1,1,0,1,1},
	{0,0,0,0,0,0,0},
};

int main() {
	int n;
	
	while (cin >> n) {
		if (n == -1) break;
		
		int p = 10;
		
		for_(i,0,n) {
			int c;
			cin >> c;
			
			for_(i,0,7) cout << (bit[c][7 - i - 1] == bit[p][7 - i - 1] ? 0 : 1);
			cout << endl;
			
			p = c;
		}
	}
}

C++: #include <cstdio>


int n,d;
int num[10]={0x3F,0x6,0x5B,0x4F,0x66,0x6D,0x7D,0x27,0x7F,0x6F};

void p(int st){
	for(int i = 6; i >= 0; i--){
		if((st&(1 << i)) !=0){
			printf("1");
		}
		else{
			printf("0");
		}
	}
	printf("\n");
}

int main(){
	while(scanf("%d",&n),n != -1){
		int st = 0;
		for(int i = 0; i < n; i++){
			scanf("%d",&d);
			st ^= num[d];
			p(st);
			st = num[d];
		}

	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int m,n,light[7]={0};
  int math[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(1){
    for(int i=0;i<7;i++){
      light[i]=0;
    }
    cin >> n;
    if(n==-1){
      break;
    }
    for(int i=0;i<n;i++){
      cin >> m;
      for(int i=0;i<7;i++){
	if(light[i]==math[m][i]){
	  cout << "0";
	}
	else{
	  cout << "1";
	}
	light[i]=math[m][i];
      }
      cout << endl;
    }
  }
  return (0);
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	int n;
	while(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()
{
    while(1)
    {
        int n;
        cin>>n;if(n==-1)return 0;
        int nb=0;
        for(int i=0;i<n;++i){
            int nn,nxb,ans=0;
            cin>>nn;
            switch(nn){
                case 0: nxb=63;break;
                case 1: nxb=6;break;
                case 2: nxb=91;break;
                case 3: nxb=79;break;
                case 4: nxb=102;break;
                case 5: nxb=109;break;
                case 6: nxb=125;break;
                case 7: nxb=39;break;
                case 8: nxb=127;break;
                case 9: nxb=111;break;
            }
            ans=nxb^nb;
            nb=nxb;
            if(ans>63){
                cout<<1;
                ans-=64;
            }else{
                cout<<0;
            }
            if(ans>31){
                cout<<1;
                ans-=32;
            }else{
                cout<<0;
            }
            if(ans>15){
                cout<<1;
                ans-=16;
            }else{
                cout<<0;
            }
            if(ans>7){
                cout<<1;
                ans-=8;
            }else{
                cout<<0;
            }
            if(ans>3){
                cout<<1;
                ans-=4;
            }else{
                cout<<0;
            }
            if(ans>1){
                cout<<1;
                ans-=2;
            }else{
                cout<<0;
            }
            if(ans>0){
                cout<<1;
                ans-=1;
            }else{
                cout<<0;
            }
            cout<<endl;
        }
    }
    return 0;
}

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

int t[10][7]={
  {1,1,1,1,1,1,0},
  {0,1,1,0,0,0,0},
  {1,1,0,1,1,0,1},
  {1,1,1,1,0,0,1},
  {0,1,1,0,0,1,1},
  {1,0,1,1,0,1,1},
  {1,0,1,1,1,1,1},
  {1,1,1,0,0,1,0},
  {1,1,1,1,1,1,1},
  {1,1,1,1,0,1,1}
};
int n,a,b;
int main(){

  while(1){
    cin>>n;
    if(n==-1)break;
    cin>>a;
    for(int i=6;i>=0;i--)cout<<t[a][i];
    cout<<endl;
    for(int j=1;j<n;j++){
      b=a;
      cin>>a;
      if(b==a)continue;
      for(int i=6;i>=0;i--){
	cout<<(t[a][i]!=t[b][i]?'1':'0');
      }
      cout<<endl;
    }
  }
  return 0;
}