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 <cstdio>
#include <iostream>
#include <bitset>
using namespace std;

int main()
{
  int seg[] = {0x3f, 0x6, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x27, 0x7f, 0x6f};
  int n;

  while (scanf("%d", &n), n != -1){
    int ans = 0;
    while (n--){
      int m;
      scanf("%d", &m);
      cout << bitset<7>(ans ^ seg[m]) << '\n';
      ans = seg[m];
    }
  }

  return (0);
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  unsigned long num[11]={63,6,91,79,66,109,125,39,127,111};
  int n,a,b=10;
  while(cin>>n,n!=-1){
    bitset<7> now((unsigned long)0);
    b=10;
    for(int i=0;i<n;i++){
      cin>>a;
      now=num[b]^num[a];
      for(int i=6;i>=0;i--){
	cout<<now[i];
      }
      cout<<endl;
      b=a;
    }
  }
}

C++: #include<stdio.h>



int main(){
int N,x;
int A[8]={0,0,0,0,0,0,0};
int n[8]={0,0,0,0,0,0,0};
int n0[8]={0,1,1,1,1,1,1};
int n1[8]={0,0,0,0,1,1,0};
int n2[8]={1,0,1,1,0,1,1};
int n3[8]={0,0,1,1,1,1,1};
int n4[8]={1,1,0,0,1,1,0};
int n5[8]={1,1,0,1,1,0,1};
int n6[8]={1,1,1,1,1,0,1};
int n7[8]={1,0,0,0,1,1,1};
int n8[8]={1,1,1,1,1,1,1};
int n9[8]={1,1,0,1,1,1,1};

while(1){
scanf("%d",&N);if(N==-1)break;
for(int i=0;i<7;i++)
A[i]=0;

for(int i=0;i<N;i++)
{
scanf("%d",&x);
switch(x){

case 0:
for(int i=0;i<7;i++)
n[i]=n0[i];
break;

case 1:
for(int i=0;i<7;i++)
n[i]=n1[i];
break;

case 2:
for(int i=0;i<7;i++)
n[i]=n2[i];
break;

case 3:
for(int i=0;i<7;i++)
n[i]=n3[i];
break;

case 4:
for(int i=0;i<7;i++)
n[i]=n4[i];
break;

case 5:
for(int i=0;i<7;i++)
n[i]=n5[i];
break;

case 6:
for(int i=0;i<7;i++)
n[i]=n6[i];
break;

case 7:
for(int i=0;i<7;i++)
n[i]=n7[i];
break;

case 8:
for(int i=0;i<7;i++)
n[i]=n8[i];
break;

case 9:
for(int i=0;i<7;i++)
n[i]=n9[i];
break;
}
for(int i=0;i<7;i++)
{if(A[i]!=n[i])printf("1");
else if(A[i]==n[i])printf("0");
A[i]=n[i];
}
printf("\n");
}
}
return 0;
}

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

int main(){
  vector<string> seg;
  int n, s;

    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 == -1) return 0;
    string start="0000000",ans="0000000";
    for(int i=0; i<n; i++){
      cin >> s;
      string result = seg[s];

      // cout << "start:  " << start << endl;
      // cout << "result: " << result << endl;

      for(int j=0; j<7; j++){
	if(start[j] == result[j]) ans[j] = '0';
	else ans[j] = '1';
      }

      cout << ans << endl;
      /*
      for(int i=0; i<7; i++)
	cout <<  ans[i]-'0';
      cout << endl;
      */
      start = seg[s];
    }

  }
}

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

const bool 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}};

bool now[7];
bool dif[7];
void init()
{
	for(int i=0;i<7;i++){
		now[i] = 0;
		dif[i] = 0;
	}
}
void show()
{
	for(int i=0;i<7;i++){
		cout << dif[i];
	}
	cout << endl;
}
void solve(int m)
{
	for(int i=0;i<7;i++){
		if(now[i]!=num[m][i]){
			dif[i] = 1;
		}else{
			dif[i] = 0;
		}
		now[i] = num[m][i];
	}
}
int main()
{
	int n;
	while(cin >> n){
		if(n<0)
			break;
		init();
		int m;
		for(int i=0;i<n;i++){
			cin >> m;
			solve(m);
			show();
		}
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <P,P> PP;
typedef pair <int,PP> PPP;

static const double eps = 1e-8;

static const string numbers[] = {"1111110","0110000","1101101","1111001","0110011",
	"1011011","1011111","1110010","1111111","1111011"};
static const int order[] = {'g'-'a','f'-'a','e'-'a','d'-'a','c'-'a','b'-'a','a'-'a'};

string changeOrder(string numbers){
	reverse(numbers.begin(),numbers.end());
	return numbers;
}

void setStage(bitset<7>& stage,bitset<7>& next){
	for(int i=0;i<7;i++){
		if(next[i] & 1){
			stage[i] = ~stage[i];
		}
	}
}

int main(){

	int n;	
	while(~scanf("%d",&n)){
		if(n==-1) break;
		bitset<7> next;
		bitset<7> stage;
		for(int i=0;i<n;i++){
			int light;
			scanf("%d",&light);
			bitset<7> num(changeOrder(numbers[light]));
			next = stage ^ num;	
			setStage(stage,next);
			printf("%s\n",next.to_string().c_str());
			
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	bool data[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 n;
	while(cin>>n&&n!=-1){
		bool state[7];
		memset(state,false,sizeof(state));
		while(n--){
			int input;
			cin>>input;
			for(int i=0;i<7;i++){
				cout<<(state[i]^data[input][i]);
				state[i]=data[input][i];
			}
			cout<<endl;
		}
	}
}

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, 1, 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);
}