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

int main(){
  int i,j,n,be,af;
  string a[10],ans;
  a[0] = "0111111";
  a[1] = "0000110";
  a[2] = "1011011";
  a[3] = "1001111";
  a[4] = "1100110";
  a[5] = "1101101";
  a[6] = "1111101";
  a[7] = "0100111";
  a[8] = "1111111";
  a[9] = "1101111";
  while(1){
    cin >> n;
    if(n == -1) break;
    for(i=0;i<n;i++){
      cin >> af;
      if(i == 0){
	ans = a[af];
      }
      else{
	for(j=0;j<7;j++){
	  if(a[af][j] == a[be][j]) ans[j] = '0';
	  else ans[j] = '1';
	}
      }
      cout << ans << endl;
      be = af;
    }
  }
  return 0;
}

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

using namespace std;

string hantei(int);

main(){
  int n, in;
  while(1){
    cin >> n;
    if(n==-1) break;
    string now="0000000";
    for(int i=0;i<n;i++){
      cin >> in;
      string tmp=hantei(in);
      string out="";
      bool hyouzi=false;
      for(int j=0;j<7;j++){
	if(now[j]==tmp[j]) out+='0';
	else{
	  out+='1';
	  hyouzi=true;
	}
      }
      if(hyouzi)
	cout << out << endl;
      now=tmp;
    }
  }
  return 0;
}


string hantei(int n){
  if(n==0)
    return "0111111";
  if(n==1)
    return "0000110";
  if(n==2)
    return "1011011";
  if(n==3)
    return "1001111";
  if(n==4)
    return "1100110";
  if(n==5)
    return "1101101";
  if(n==6)
    return "1111101";
  if(n==7)
    return "0100111";
  if(n==8)
    return "1111111";
  if(n==9)
    return "1101111";
}

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

int main(){

  int b[11] = {63,6,91,79,102,109,125,39,127,111,0};
  int now = 11;
  int k;
  int n;

  while(cin >> n){
    if(n == -1) break;
    
    cin >> k;
    for(int i=6;i>-1;i--) printf("%d", (b[k]>>i)&1);
    now = k;
    cout << endl;
    n--;
    
    while(n--){
      cin >> k;
      int p = (b[now]^b[k]);
      for(int i=6;i>-1;i--) printf("%d", (p>>i)&1);
      printf( "\n" );
      now = k;
    }
  }

}

C++: #include<cstdio>
#include<iostream>
using namespace std;
string str[10] = {
	"0111111","0000110","1011011","1001111","1100110",
	"1101101","1111101","0100111","1111111","1101111"
};
string func(string now, int index) {
	string ret = "";
	for(int i = 0; i < 7; i++) ret += (now[i] != str[index][i]) + '0';
	return ret;
}
int main() {
	int n;
	while(cin >> n,n != -1) {
		string now = "0000000";
		for(int i = 0; i < n; i++) {
			int a;
			cin >> a;
			cout << func(now, a) << endl;
			now = str[a];
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  int s;
  while(cin>>n){
    if(n==-1) break;
    for(int i=0;i<n;i++){
      cin >> s;
      if(s==0) cout << "0111111" << endl;
      else if(s==1) cout << "0000110" << endl;
      else if(s==2) cout << "1011011" << endl;
      else if(s==3) cout << "1001111" << endl;
      else if(s==4) cout << "1100110" << endl;
      else if(s==5) cout << "1011101" << endl;
      else if(s==6) cout << "1111101" << endl;
      else if(s==7) cout << "0100111" << endl;
      else if(s==8) cout << "1111111" << endl;
      else if(s==9) cout << "1101111" << endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  while(cin>>n,n>=0){
    string num[10]={"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
    string nows="0000000";
    for(int i=0;i<n;i++){
      int d;cin>>d;
      for(int j=0;j<7;j++){
	if(num[d][j]!=nows[j]){
	  cout<<1;
	}else
	  cout<<0;
      }
      cout<<endl;
      nows=num[d];
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	string b[10] = { "0111111","0000110","1011011","1001111",
	"1100110","1101101","1111101","0100111","1111111","1101111" };
	while (cin >> n&&n != -1) {
		string c = "0000000";
		for (int z = 0; z < n; z++) {
			int a;
			cin >> a;
			string d = "";
			for (int i = 0; i < 7; i++) {
				if (b[a][i] != c[i])
					d += "1";
				else
					d += "0";
			}																																									
			c = b[a];
			cout << d << endl;
		}
	}
}

C++: #include <cstdio>
#include <stack>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <climits>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

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

int main()
{
	const char* str[] = {
		"0111111",
		"0000110",
		"1011011",
		"1001111",
		"1100110",
		"1101101",
		"1111101",
		"0100111",
		"1111111",
		"1101111"
	};
	int n;
	while(scanf("%d", &n), ~n){
		char s[] = "0000000";
		rep(i, n){
			int a;
			scanf("%d", &a);
			rep(i, 7){
				if(s[i] != str[a][i])
					putchar('1');
				else
					putchar('0');
				s[i] = str[a][i];
			}
			puts("");
		}
	}
	return 0;
}

C++: #include<stdio.h>
int main()
{
	char*s[]={	"0111111",
				"0000110",
				"1011011",
				"1001111",
				"1100110",
				"1101101",
				"1111101",
				"0100111",
				"1111111",
				"1101111",};
	int n,x,i;
	while(scanf("%d",&n),n>=0)
	{
		char l[10]="0000000";
		while(n--)
		{
			scanf("%d",&x);
			for(i=0;i<7;++i)
				printf("%d",l[i]!=s[x][i]),l[i]=s[x][i];
			puts("");
		}
	}
	return 0;
}

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

int main() {
  const string list[10] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
  int M[10];
  for(int i=0; i<10; i++)
    for(int j=0; j<7; j++)
      M[i] += (list[i][j]-'0') << j;
  
  int N;
  while(cin >> N && (N!=-1)) {
    int S = 0;
    for(int i=0; i<N; i++) {
      int x; cin >> x;
      S ^= M[x];
      for(int j=0; j<7; j++) {
        cout << (S >> j & 1);
      }
      S = M[x];
      cout << endl;
    }
  }
  return 0;
}

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

using namespace std;


int main(){
    while(1){
    int a;
    vector<int> seg  {0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,0b1101101,0b1111101,0b0100111,0b1111111,0b1101111};
    cin >> a;
    if(a == -1){
        
        return 0;
    }else{
        int b,c,d;
        c = 0b0000000;
        
    for(int i=0;i<a;i++){
        
        cin >>b;
        d = seg[b]^c;
        cout << bitset<7>(d) <<endl;
        c = seg[b];
    }
    }
    }
}