Language: C++

#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = long long;

int main()
{
  char a,b,c,d;
  int A,B,C,D;
  scanf("%c%c%c%c",&a,&b,&c,&d);
  A = a-'0'; B = b-'0'; C = c-'0'; D = d-'0';
  // +++ 000
  if(A+B+C+D == 7) printf("%d+%d+%d+%d=7\n", A,B,C,D);
  // ++- 001
  else if(A+B+C-D == 7) printf("%d+%d+%d-%d=7\n", A,B,C,D);
  // +-+ 010
  else if(A+B-C+D == 7) printf("%d+%d-%d+%d=7\n", A,B,C,D);
  // +-- 011
  else if(A+B-C-D == 7) printf("%d+%d-%d-%d=7\n", A,B,C,D);
  // -++ 100
  else if(A-B+C+D == 7) printf("%d-%d+%d+%d=7\n", A,B,C,D);
  // -+- 101
  else if(A-B+C-D == 7) printf("%d-%d+%d-%d=7\n", A,B,C,D);
  // --+ 110
  else if(A-B-C+D == 7) printf("%d-%d-%d+%d=7\n", A,B,C,D);
  // --- 111
  else if(A-B-C-D == 7) printf("%d-%d-%d-%d=7\n", A,B,C,D);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'scanf' was not declared in this scope
    9 |   scanf("%c%c%c%c",&a,&b,&c,&d);
      |   ^~~~~
a.cc:12:20: error: 'printf' was not declared in this scope
   12 |   if(A+B+C+D == 7) printf("%d+%d+%d+%d=7\n", A,B,C,D);
      |                    ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | #define rep(i, n) for(int i=0; i<n; ++i)
a.cc:14:25: error: 'printf' was not declared in this scope
   14 |   else if(A+B+C-D == 7) printf("%d+%d+%d-%d=7\n", A,B,C,D);
      |                         ^~~~~~
a.cc:14:25: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:16:25: error: 'printf' was not declared in this scope
   16 |   else if(A+B-C+D == 7) printf("%d+%d-%d+%d=7\n", A,B,C,D);
      |                         ^~~~~~
a.cc:16:25: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:18:25: error: 'printf' was not declared in this scope
   18 |   else if(A+B-C-D == 7) printf("%d+%d-%d-%d=7\n", A,B,C,D);
      |                         ^~~~~~
a.cc:18:25: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:20:25: error: 'printf' was not declared in this scope
   20 |   else if(A-B+C+D == 7) printf("%d-%d+%d+%d=7\n", A,B,C,D);
      |                         ^~~~~~
a.cc:20:25: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:22:25: error: 'printf' was not declared in this scope
   22 |   else if(A-B+C-D == 7) printf("%d-%d+%d-%d=7\n", A,B,C,D);
      |                         ^~~~~~
a.cc:22:25: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:24:25: error: 'printf' was not declared in this scope
   24 |   else if(A-B-C+D == 7) printf("%d-%d-%d+%d=7\n", A,B,C,D);
      |                         ^~~~~~
a.cc:24:25: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:26:25: error: 'printf' was not declared in this scope
   26 |   else if(A-B-C-D == 7) printf("%d-%d-%d-%d=7\n", A,B,C,D);
      |                         ^~~~~~
a.cc:26:25: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'