Language: C++

#include <cstdio>
using namespace std;

int main(){
  int n ,num;
  string seg="0000000"; // a b c d e f g の順
  string set[10]={ /* 各数字のビット */
    "0111111", // 0
    "0000110", // 1
    "1011011", // 2
    "1001111", // 3
    "1100110", // 4
    "1101101", // 5
    "1111101", // 6
    "0100111", // 7
    "1111111", // 8
    "1101111"  // 9
  };

  while( true ){ // -1まで
    cin >> n;
    if( n == -1 ){
      break;
    }

    for( int i=0 ; i<n ; i++ ){
      cin >> num;
      for( int j=0 ; j<7 ; j++ ){
	if( seg[j] != set[num][j] ){ // ビットが違ったら
	  cout << '1';
	}
	else{ // 同じなら
	  cout << '0' ;
	}
      }
      seg = set[num];
      cout << endl;
    }

    seg = "0000000"; // セグメントを0のに初期化
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'string' was not declared in this scope
    6 |   string seg="0000000"; // a b c d e f g の順
      |   ^~~~~~
a.cc:2:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
    1 | #include <cstdio>
  +++ |+#include <string>
    2 | using namespace std;
a.cc:7:9: error: expected ';' before 'set'
    7 |   string set[10]={ /* 各数字のビット */
      |         ^~~~
      |         ;
a.cc:21:5: error: 'cin' was not declared in this scope
   21 |     cin >> n;
      |     ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <cstdio>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:29:13: error: 'seg' was not declared in this scope
   29 |         if( seg[j] != set[num][j] ){ // ビットが違ったら
      |             ^~~
a.cc:29:23: error: 'set' was not declared in this scope
   29 |         if( seg[j] != set[num][j] ){ // ビットが違ったら
      |                       ^~~
a.cc:2:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
    1 | #include <cstdio>
  +++ |+#include <set>
    2 | using namespace std;
a.cc:30:11: error: 'cout' was not declared in this scope
   30 |           cout << '1';
      |           ^~~~
a.cc:30:11: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:33:11: error: 'cout' was not declared in this scope
   33 |           cout << '0' ;
      |           ^~~~
a.cc:33:11: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:36:7: error: 'seg' was not declared in this scope
   36 |       seg = set[num];
      |       ^~~
a.cc:36:13: error: 'set' was not declared in this scope
   36 |       seg = set[num];
      |             ^~~
a.cc:36:13: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
a.cc:37:7: error: 'cout' was not declared in this scope
   37 |       cout << endl;
      |       ^~~~
a.cc:37:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:37:15: error: 'endl' was not declared in this scope
   37 |       cout << endl;
      |               ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <cstdio>
  +++ |+#include <ostream>
    2 | using namespace std;
a.cc:40:5: error: 'seg' was not declared in this scope
   40 |     seg = "0000000"; // セグメントを0のに初期化
      |     ^~~