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 <cstring>

using namespace std;

int main()
{
  int n, c;
  const int num[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, 0},
    {0, 1, 0, 0, 1, 1, 1},
    {1, 1, 1, 1, 1, 1, 1},
    {1, 1, 0, 1, 1, 1, 1}
  };

  while (cin >> n, n != -1){
    int seg[] = {0, 0, 0, 0, 0, 0, 0};
    while (n--){
      cin >> c;
      for (int i = 0; i < 7; i++){
        if (seg[i] != num[c][i]){
          seg[i] = 1;
        }
        else {
          seg[i] = 0;
        }
        cout << seg[i];
      }
      memcpy(seg, num[c], sizeof(int) * 7);
      cout << endl;
    }
  }

  return (0);
}

C++: #include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	int n;
	map<int,string> d;
	
	d[0]="0111111";
	d[1]="0000110";
	d[2]="1011011";
	d[3]="1001111";
	d[4]="1100110";
	d[5]="1101101";
	d[6]="1111101";
	d[7]="0100111";
	d[8]="1111111";
	d[9]="1101111";
	
	while(cin>>n,n!=-1){
		int a;
		cin>>a;
		cout<<d[a]<<endl;
		n--;
		for(int i=0;i<n;i++){
			int b;
			cin>>b;
			string s;
			for(int j=0;j<7;j++){
			if(d[a][j]==d[b][j])
				s+="0";
			else
				s+="1";
			}
			cout<<s<<endl;
			a=b;
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
   while(1){
      int n;
      cin >> n;
      if(n==-1){
         break;
      }
      vector<int> seg = {0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,0b1101101,0b1111101,0b0100111,0b1111111,0b1101111};
      vector<int> vec(n+1);
      vec[0] = 0b0000000;
      for(int i=1;i<n+1;i++){
         cin >> vec[i];
         vec[i] = seg[vec[i]];
      }
      for(int i=0;i<n;i++){
         cout << bitset<7>(vec[i]^vec[i+1]) << endl;
      }
   }

}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n<0)break;
    char s[10][10]={"0111111","0000110",
                    "1011011","1001111",
                    "1100110","1101101",
                    "1111101","0100111",
                    "1111111","1101111"};
    int d;
    cin>>d;
    cout<<s[d]<<endl;
    int b=d;
    rep(i,n-1){
      cin>>d;
      rep(j,7)
        if(s[b][j]==s[d][j])
          cout<<"0";
        else
          cout<<"1";
      cout<<endl;
      b=d;
    }
  }
}

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

using namespace std;

vector<unsigned int> table { 63, 6, 91, 79, 102, 109, 125, 39, 127, 111 };

void solve(int from, int to)
{
	unsigned int b0 = table[from];
	unsigned int b1 = table[to];
	cout << static_cast<bitset<7>>( b0 ^ b1 ) << endl;
}

int main(int argc, char* argv[])
{
	int num, d;
	vector<int> ds;

	while(1) {
		cin >> num;
		if( num == -1 )
			break;
		for( int i = 0; i < num; i++ ) {
			cin >> d;
			ds.push_back(d);
		}
		int v0 = -1;
		for( auto  v1 : ds ) {
			solve(v0, v1);
			v0 = v1;
		}
	}

    return 0;
}

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
int num[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}};
int main(){
	int n;
	int segment[7]={0,0,0,0,0,0,0};
	int display[7];
	while(cin>>n,n!=-1){
		rep(i,7)segment[i]=0;
		for(int j=0;j<n;j++){
			int nm;
			cin>>nm;
			rep(i,7){
				display[i]=segment[i] xor num[nm][i];
				segment[i]=num[nm][i];
			}
			string s="";
			rep(i,7)s+=(char)(display[i]+'0');
			cout<<s<<endl;
		}
	}
	return 0;
}

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

using namespace std;

int main(void){
	string state[10];
	int n;
	
	state[0] = "0111111";
	state[1] = "0000110";
	state[2] = "1011011";
	state[3] = "1001111";
	state[4] = "1100110";
	state[5] = "1101101";
	state[6] = "1111101";
	state[7] = "0000111";
	state[8] = "1111111";
	state[9] = "1101111";
	
	while(cin >> n && n != -1){
		string cur = "0000000";
		string out = "0000000";
		int t;
		for(int i=0;i<n;i++){
			cin >> t;
			for(int i=0;i<7;i++){
				cur[i] == state[t][i]?out[i]='0':out[i]='1';
			}
			cout << out <<endl;
			cur = state[t];
		}
	}
}

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

int segment[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}
} ;

main(){
	int n,m ;
	while( cin >> n , n ){
		if( n == -1 ) break ;
		
		int t[7] = {} ;
		for( int i=0 ; i<n ; i++ ){
			cin >> m ;
			for( int j=0 ; j<7 ; j++ ){
				if( segment[m][j] ){
					if( t[j] ) cout << 0 ;
					else cout << 1 ;
				}
				else{
					if( t[j] ) cout << 1 ;
					else cout << 0 ;
				}
				t[j] = segment[m][j] ;
			}
			cout << endl ;
		}
	}
}

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

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

using namespace std;

int main()
{
	map<int,string> m;
	m[0] = "1111110";
	m[1] = "0110000";
	m[2] = "1101101";
	m[3] = "1111001";
	m[4] = "0110011";
	m[5] = "1011011";
	m[6] = "1011111";
	m[7] = "1110010";
	m[8] = "1111111";
	m[9] = "1111011";

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

		string now = "0000000";
		bool flag[7];
		rep(i,7) flag[i] = false;

		rep(i,n)
		{
			int k;
			cin >> k;
		
			string ans = "0000000";
			rep(j,7)
			{
				if(now[j] != m[k][j])
				{
					ans[j] = '1';
				}
			}
			now = m[k];

			reverse(ans.begin(),ans.end());
			cout << ans << endl;
		}
	}
}