Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<math.h>
int main(void){
	string s[4]:
  	cin >> string;
  	int a,b,c,d,i,sum;
  	char c1,c2,c3;
  	a = stoi(s.substr(0,1));
  	b = stoi(s.substr(1,1));
  	c = stoi(s.substr(2,1));
  	d = stoi(s.substr(3,1));
  	for (i=0;i<8,i++){
    	sum = a + (int)(pow(-1,i))*b + (int)(pow(-1,i%2))*c + (int)(pow(-1,i%3)*d;
        if (sum==7){
        	if((int)(pow(-1,i))*b == 1){
            	c1 = "+";
            }else{
            	c1 = "-";
            }
          	if((int)(pow(-1,i%2))*c == 1){
            	c2 = "+";
            }else{
            	c2 = "-";
            }
          	if((int)(pow(-1,i))*d == 1){
            	c3 = "+";
            }else{
            	c3 = "-";
            }
          	cout << a << c1 << b << c2 << c << c3 << d ;
          	return 0;
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: 'string' was not declared in this scope
    6 |         string s[4]:
      |         ^~~~~~
a.cc:6:9: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:10:18: error: 's' was not declared in this scope
   10 |         a = stoi(s.substr(0,1));
      |                  ^
a.cc:10:13: error: 'stoi' was not declared in this scope; did you mean 'std::__cxx11::stoi'?
   10 |         a = stoi(s.substr(0,1));
      |             ^~~~
      |             std::__cxx11::stoi
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:4432:3: note: 'std::__cxx11::stoi' declared here
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:14:25: error: expected ';' before ')' token
   14 |         for (i=0;i<8,i++){
      |                         ^
      |                         ;
a.cc:15:82: error: expected ')' before ';' token
   15 |         sum = a + (int)(pow(-1,i))*b + (int)(pow(-1,i%2))*c + (int)(pow(-1,i%3)*d;
      |                                                                    ~             ^
      |                                                                                  )
a.cc:18:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   18 |                 c1 = "+";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:20:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   20 |                 c1 = "-";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:23:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   23 |                 c2 = "+";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:25:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   25 |                 c2 = "-";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:28:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   28 |                 c3 = "+";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:30:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   30 |                 c3 = "-";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:32:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   32 |                 cout << a << c1 << b << c2 << c << c3 << d ;
      |                 ^~~~
      |                 std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~