Language: C++

int main()
{
    int abcd;
    int a, b, c, d;
    cin >> abcd;
    // 各変数に値を代入する
    a = abcd / 1000;
    abcd -= 1000*a;
    b = abcd / 100;
    abcd -= 100*b;
    c = abcd / 10;
    abcd -= c*10;
    d = abcd;
    // cout << a << endl << b << endl << c << endl << d << endl;
    string op1, op2, op3;
    int ab, cd, ab_cd;
    bool isSeven = false;;
    // 考えられる符号の８パターンを試行する
    for(int i=0; i<2; i++){
        for(int j=0; j<2; j++){
            for(int k=0; k<2; k++){
                if(i == 0) ab = a + b;
                else ab = a - b;
                if(k == 0) cd = c + d;
                else cd = c - d;
                if(j == 0) ab_cd = ab + cd;
                else ab_cd = ab - cd;
                if(ab_cd == 7){
                    isSeven = true;
                    if(i == 0) op1 = "+";
                    else op1 = "-";
                    if(k == 0) op3 = "+";
                    else op3 = "-";
                    if(j == 0) op2 = "+";
                    else op2 = "-";
                }
            }
        }
    }
    if(isSeven) cout << a << op1 << b << op2 << c << op3 << d << "=" << 7 << endl;
    else cout << "No" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin >> abcd;
      |     ^~~
a.cc:15:5: error: 'string' was not declared in this scope
   15 |     string op1, op2, op3;
      |     ^~~~~~
a.cc:30:32: error: 'op1' was not declared in this scope
   30 |                     if(i == 0) op1 = "+";
      |                                ^~~
a.cc:31:26: error: 'op1' was not declared in this scope
   31 |                     else op1 = "-";
      |                          ^~~
a.cc:32:32: error: 'op3' was not declared in this scope
   32 |                     if(k == 0) op3 = "+";
      |                                ^~~
a.cc:33:26: error: 'op3' was not declared in this scope
   33 |                     else op3 = "-";
      |                          ^~~
a.cc:34:32: error: 'op2' was not declared in this scope
   34 |                     if(j == 0) op2 = "+";
      |                                ^~~
a.cc:35:26: error: 'op2' was not declared in this scope
   35 |                     else op2 = "-";
      |                          ^~~
a.cc:40:17: error: 'cout' was not declared in this scope
   40 |     if(isSeven) cout << a << op1 << b << op2 << c << op3 << d << "=" << 7 << endl;
      |                 ^~~~
a.cc:40:30: error: 'op1' was not declared in this scope
   40 |     if(isSeven) cout << a << op1 << b << op2 << c << op3 << d << "=" << 7 << endl;
      |                              ^~~
a.cc:40:42: error: 'op2' was not declared in this scope
   40 |     if(isSeven) cout << a << op1 << b << op2 << c << op3 << d << "=" << 7 << endl;
      |                                          ^~~
a.cc:40:54: error: 'op3' was not declared in this scope
   40 |     if(isSeven) cout << a << op1 << b << op2 << c << op3 << d << "=" << 7 << endl;
      |                                                      ^~~
a.cc:40:78: error: 'endl' was not declared in this scope
   40 |     if(isSeven) cout << a << op1 << b << op2 << c << op3 << d << "=" << 7 << endl;
      |                                                                              ^~~~
a.cc:41:10: error: 'cout' was not declared in this scope
   41 |     else cout << "No" << endl;
      |          ^~~~
a.cc:41:26: error: 'endl' was not declared in this scope
   41 |     else cout << "No" << endl;
      |                          ^~~~