Language: C++

#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int data[4];

void string_to_int(string s){
  rep(i,4){
    char c=s[i];
    //cout<<c-'0'<<endl;
    data[i]=(c-'0');
  }
}

void solve(){
  int sum=0;
  rep(i,2){
    rep(j,2){
      rep(k,2){
	sum=data[0];
	string ans=to_string(data[0]);
	if(i==0){
	  sum+=data[1];
	  ans=ans+'+'+to_string(data[1]);
	}else{
	  sum-=data[1];
	  ans=ans+'-'+to_string(data[1]);
	}

	if(j==0){
	  sum+=data[2];
	  ans=ans+'+'+to_string(data[2]);
	}else{
	  sum-=data[2];
	  ans=ans+'-'+to_string(data[2]);
	}

	if(k==0){
	  sum+=data[3];
	  ans=ans+'+'+to_string(data[3]);
	}else{
	  sum-=data[1];
	  ans=ans+'-'+to_string(data[3]);
	}

	if(sum==7){
	  ans=ans+"=7";
	  cout<<ans<<endl;
	  return ;
	}
      }
    }
  }
}

int main(){
  string s;
  cin>>s;
  string_to_int(s);
  solve();
  return 0;
}


Compiler output:
a.cc:37:6: error: variable or field 'string_to_int' declared void
   37 | void string_to_int(string s){
      |      ^~~~~~~~~~~~~
a.cc:37:20: error: 'string' was not declared in this scope
   37 | void string_to_int(string s){
      |                    ^~~~~~
a.cc:11:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
   10 | #include <ctime>
  +++ |+#include <string>
   11 | #define INF 100000000
a.cc: In function 'void solve()':
a.cc:50:13: error: reference to 'data' is ambiguous
   50 |         sum=data[0];
      |             ^~~~
In file included from /usr/include/c++/14/deque:68,
                 from /usr/include/c++/14/stack:62,
                 from a.cc:2:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:35:5: note:                 'int data [4]'
   35 | int data[4];
      |     ^~~~
a.cc:51:9: error: 'string' was not declared in this scope
   51 |         string ans=to_string(data[0]);
      |         ^~~~~~
a.cc:51:9: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:53:16: error: reference to 'data' is ambiguous
   53 |           sum+=data[1];
      |                ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:35:5: note:                 'int data [4]'
   35 | int data[4];
      |     ^~~~
a.cc:54:11: error: 'ans' was not declared in this scope
   54 |           ans=ans+'+'+to_string(data[1]);
      |           ^~~
a.cc:54:33: error: reference to 'data' is ambiguous
   54 |           ans=ans+'+'+to_string(data[1]);
      |                                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:35:5: note:                 'int data [4]'
   35 | int data[4];
      |     ^~~~
a.cc:54:23: error: 'to_string' was not declared in this scope
   54 |           ans=ans+'+'+to_string(data[1]);
      |                       ^~~~~~~~~
a.cc:54:23: note: 'std::to_string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:56:16: error: reference to 'data' is ambiguous
   56 |           sum-=data[1];
      |                ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:35:5: note:                 'int data [4]'
   35 | int data[4];
      |     ^~~~
a.cc:57:11: error: 'ans' was not declared in this scope
   57 |           ans=ans+'-'+to_string(data[1]);
      |           ^~~
a.cc:57:33: error: reference to 'data' is ambiguous
   57 |           ans=ans+'-'+to_string(data[1]);
      |                                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:35:5: note:                 'int data [4]'
   35 | int data[4];
      |     ^~~~
a.cc:57:23: error: 'to_string' was not declared in this scope
   57 |           ans=ans+'-'+to_string(data[1]);
      |                       ^~~~~~~~~
a.cc:57:23: note: 'std::to_string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:61:16: error: reference to 'data' is ambiguous
   61 |           sum+=data[2];
      |                ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:35:5: note:                 'int data [4]'
   35 | int data[4];
      |     ^~~~
a.cc:62:11: error: 'ans' was not declared in this scope
   62 |           ans=ans+'+'+to_string(data[2]);
      |           ^~~
a.cc:62:33: error: reference to 'data' is ambiguous
   62 |           ans=ans+'+'+to_string(data[2]);
      |                                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:35:5: note:                 'int data [4]'
   35 | int data[4];
      |     ^~~~
a.cc:62:23: error: 'to_string' was not declared in this scope
   62 |           ans=ans+'+'+to_string(data[2]);
      |                       ^~~~~~~~~
a.cc:62:23: note: 'std::to_string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:64:16: error: reference to 'data' is ambiguous
   64 |           sum-=data[2];
      |                ^~~~
/usr/include/c++/14/bits/ra