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<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

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

int main()
{
	int n;
	while (1) 
	{
		string s = "";
		cin >> n;
		if (n == -1)break;

		rep(i, n) {
			int num; cin >> num;
			if (i == 0) 
				cout << str[num] << endl;
			else {
				string tmp = "";
				rep(i, 7) {
					if (str[num][i] != s[i])
						tmp += "1";
					else
						tmp += "0";
				}
				cout << tmp << endl;
			}
			s = str[num];
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){
  int ans[10][7] =  {
    {0,1,1,1,1,1,1},  //0
    {0,0,0,0,1,1,0},  //1
    {1,0,0,1,0,1,1},  //2
    {1,1,1,1,0,0,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 n;
  while(cin>>n,n>0){
    int number;
    int now[7]={0,0,0,0,0,0};
    for(int j = 0 ; j < n ; j ++){
      cin>>number;
      for(int i = 0 ; i < 7 ; i ++){
        cout<<(ans[number][i]==now[i]?0:1);
        now[i]=ans[number][i];
      }
      cout<<endl;
    }
  }
}

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

int num[11][7] = {{0,1,1,1,1,1,1},
		  {0,0,0,0,1,1,0},
		  {0,0,0,0,1,1,0},
		  {1,0,1,1,0,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},
		  {0,0,0,0,0,0,0}}; 
int main(){

  int n;
  while(1){
    cin >> n;
    if(n==-1) break;
    int pre =10,next;
    for(int i=0;i<n;i++){
      cin  >> next;
      for(int j=0;j<7;j++){
	if(num[pre][j] != num[next][j]) cout << "1";
	else cout << "0";
      }
      pre = next;
      cout << "\n";
    }

  }

}

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

int main() {
    const char* numberSegments[] = {
        "0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111",
    };
    while (true) {
        int n;
        cin >> n;
        if (n == -1) {
            break;
        }
        char number[] = "0000000";
        for (int i = 0; i < n; i++) {
            int a;
            cin >> a;
            char output[9] = {};
            for (int j = 0; j < (int) (sizeof number / sizeof *number) - 1; j++) {
                if (number[j] == numberSegments[a][j]) {
                    output[j] = '0';
                } else {
                    number[j] = numberSegments[a][j];
                    output[j] = '1';
                }
            }
            cout << output << endl;
        }
    }
}

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

int main()
{
    bool s[11][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},{0,0,0,0,0,0,0}};
    int n, d;

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

        for( int i = 0; i < 7; i++ )
            s[10][i] = 0;
        
        for( int i = 0; i < n; i++ )
        {
            cin >> d;
            for( int j = 0; j < 7; j++ )
            {
                bool a = s[d][j] ^ s[10][j];
                cout << a;
                s[10][j] = s[d][j];
            }
            cout << endl;
        }
    }
    return 0;
}

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

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

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

    string s = "0000000";
    while (n--) {
      int d;
      cin >> d;
      for (int i = 0; i < 7; ++i) {
	if (s[i] == seg[d][i])
	  cout << "0";
	else
	  cout << "1";
      }
      cout << endl;
      s = seg[d];
    }
  }
  return 0;
}

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

int main(){
    int n;
    vector<int> seg{0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,0b1101101,0b1111101,0b0100111,0b1111111,0b1101111};
    while(1){
        cin>>n;
        if(n==-1){
            return 0;
        }
        vector<int> d(n);
        int x = 0;
        for(int i=0;i<n;i++){
            cin>>d.at(i);
        }
        for(int i=0;i<n;i++){
            int y=x^seg.at(d.at(i));
            cout<<(bitset<7>(y))<<endl;
            x = seg.at(d.at(i));
        }
    }
}

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

using namespace std;    
const int turn[10][8]={{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 main(void){
	int n;
	int a,b;
	int seven[8];
	while(1){
		cin >> n;
		if(n==-1)break;
		memset(seven,0,sizeof(seven));
		for(a=0;a<n;a++){
			int nn;
			cin >> nn;
			for(b=0;b<7;b++){
				if(turn[nn][b]!=seven[b])seven[b]=1;
				else seven[b]=0;
			}
			for(b=6;b>=0;b--)printf("%d",seven[b]);
			printf("\n");
			for(b=0;b<7;b++)seven[b]=turn[nn][b];
		}
	}
	return 0;
}

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

string swith;
string snum[] = {  "0111111",  "0000110",  "1011011","1001111",
		   "1100110",  "1101101",  "1111101",  "0100111",
		   "1111111",  "1101111",  "1000110"};

void kirikae(int a){
  for(int i = 0 ; i < 7 ; i++){
    if(snum[a][i] != swith[i])cout << "1";
    else cout << "0";
  }
  cout << endl;
  swith = snum[a];
}

int main(){
  int n;

  while( cin >> n ){

    if(n == -1)break;
    swith = "0000000";
    for(int i = 0 ; i < n ; i++){
      int num;
      cin >> num;
      if(num == -1)num = 10;
      kirikae(num);
    }
  }
  return 0;
}

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