Language: C++

#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int ope(int a, int b, int i){
    if(i == 0)
        return a + b;
    else if(i == 1)
        return a - b;
    else
        return a * b;
}

void solve(vector<int> a)
{
    char c[] = {'+', '-', '*'};

    sort(a.begin(), a.end());
    do{
        for(int i=0; i<27; ++i){
            int b1 = i % 3;
            int b2 = i / 3 % 3;
            int b3 = i / 9;
            if(ope(ope(a[0], a[1], b1), ope(a[2], a[3], b2), b3) == 10){
                cout << "((" << a[0] << c[i] << a[1] << ')' << c[k] << '(' << a[2] << c[j] << a[3] << "))" << endl;
                return;
            }
            if(ope(ope(ope(a[0], a[1], b1), a[2], b2), a[3], b3) == 10){
                cout << "(((" << a[0] << c[i] << a[1] << ')' << c[j] << a[2] << ')' << c[k] << a[3] << ')' << endl;
                return;
            }
            if(ope(ope(a[0], ope(a[1], a[2], b1), b2), a[3], b3) == 10){
                cout << "((" << a[0] << c[j] << '(' << a[1] << c[i] << a[2] << "))" << c[k] << a[3] << ')' << endl;
                return;
            }
        }
    }while(next_permutation(a.begin(), a.end()));

    cout << '0' << endl;
}

int main()
{
    for(;;){
        vector<int> a(4);
        for(int i=0; i<4; ++i){
            cin >> a[i];
            if(a[i] == 0)
                return 0;
        }

        solve(a);
    }
}

Compiler output:
a.cc: In function 'void solve(std::vector<int>)':
a.cc:39:66: error: 'k' was not declared in this scope
   39 |                 cout << "((" << a[0] << c[i] << a[1] << ')' << c[k] << '(' << a[2] << c[j] << a[3] << "))" << endl;
      |                                                                  ^
a.cc:39:89: error: 'j' was not declared in this scope
   39 |                 cout << "((" << a[0] << c[i] << a[1] << ')' << c[k] << '(' << a[2] << c[j] << a[3] << "))" << endl;
      |                                                                                         ^
a.cc:43:67: error: 'j' was not declared in this scope
   43 |                 cout << "(((" << a[0] << c[i] << a[1] << ')' << c[j] << a[2] << ')' << c[k] << a[3] << ')' << endl;
      |                                                                   ^
a.cc:43:90: error: 'k' was not declared in this scope
   43 |                 cout << "(((" << a[0] << c[i] << a[1] << ')' << c[j] << a[2] << ')' << c[k] << a[3] << ')' << endl;
      |                                                                                          ^
a.cc:47:43: error: 'j' was not declared in this scope
   47 |                 cout << "((" << a[0] << c[j] << '(' << a[1] << c[i] << a[2] << "))" << c[k] << a[3] << ')' << endl;
      |                                           ^
a.cc:47:90: error: 'k' was not declared in this scope
   47 |                 cout << "((" << a[0] << c[j] << '(' << a[1] << c[i] << a[2] << "))" << c[k] << a[3] << ')' << endl;
      |                                                                                          ^