Language: C++


//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool flag=true;


int main() {
    int S,A,B,C,D;
    cin>>S;

    D=S%10;
    S=S/10;
    C=S%10;
    S=S/10;
    B=S%10;
    S=S/10;
    A=S%10;
    
    string ans;
    if(A+B+C+D==7){ans=to_string(A)+'+'+to_string(C)+'+'+to_string(C)+'+'+to_string(D)+'=7';}
    if(A+B+C-D==7){ans=to_string(A)+'+'+to_string(C)+'+'+to_string(C)+'-'+to_string(D)+'=7';}
    if(A+B-C+D==7){ans=to_string(A)+'+'+to_string(C)+'-'+to_string(C)+'+'+to_string(D)+'=7';}
    if(A+B-C-D==7){ans=to_string(A)+'+'+to_string(C)+'-'+to_string(C)+'-'+to_string(D)+'=7';}
    if(A-B+C+D==7){ans=to_string(A)+'-'+to_string(C)+'+'+to_string(C)+'+'+to_string(D)+'=7';}
    if(A-B+C-D==7){ans=to_string(A)+'-'+to_string(C)+'+'+to_string(C)+'-'+to_string(D)+'=7';}
    if(A-B-C+D==7){ans=to_string(A)+'-'+to_string(C)+'-'+to_string(C)+'+'+to_string(D)+'=7';}
    if(A-B-C-D==7){ans=to_string(A)+'-'+to_string(C)+'-'+to_string(C)+'-'+to_string(D)+'=7';}
    cout<< ans;

  return 0;
}


Compiler output:
a.cc:57:88: warning: multi-character character constant [-Wmultichar]
   57 |     if(A+B+C+D==7){ans=to_string(A)+'+'+to_string(C)+'+'+to_string(C)+'+'+to_string(D)+'=7';}
      |                                                                                        ^~~~
a.cc:58:88: warning: multi-character character constant [-Wmultichar]
   58 |     if(A+B+C-D==7){ans=to_string(A)+'+'+to_string(C)+'+'+to_string(C)+'-'+to_string(D)+'=7';}
      |                                                                                        ^~~~
a.cc:59:88: warning: multi-character character constant [-Wmultichar]
   59 |     if(A+B-C+D==7){ans=to_string(A)+'+'+to_string(C)+'-'+to_string(C)+'+'+to_string(D)+'=7';}
      |                                                                                        ^~~~
a.cc:60:88: warning: multi-character character constant [-Wmultichar]
   60 |     if(A+B-C-D==7){ans=to_string(A)+'+'+to_string(C)+'-'+to_string(C)+'-'+to_string(D)+'=7';}
      |                                                                                        ^~~~
a.cc:61:88: warning: multi-character character constant [-Wmultichar]
   61 |     if(A-B+C+D==7){ans=to_string(A)+'-'+to_string(C)+'+'+to_string(C)+'+'+to_string(D)+'=7';}
      |                                                                                        ^~~~
a.cc:62:88: warning: multi-character character constant [-Wmultichar]
   62 |     if(A-B+C-D==7){ans=to_string(A)+'-'+to_string(C)+'+'+to_string(C)+'-'+to_string(D)+'=7';}
      |                                                                                        ^~~~
a.cc:63:88: warning: multi-character character constant [-Wmultichar]
   63 |     if(A-B-C+D==7){ans=to_string(A)+'-'+to_string(C)+'-'+to_string(C)+'+'+to_string(D)+'=7';}
      |                                                                                        ^~~~
a.cc:64:88: warning: multi-character character constant [-Wmultichar]
   64 |     if(A-B-C-D==7){ans=to_string(A)+'-'+to_string(C)+'-'+to_string(C)+'-'+to_string(D)+'=7';}
      |                                                                                        ^~~~
a.cc: In function 'int main()':
a.cc:57:87: error: no match for 'operator+' (operand types are 'std::__cxx11::basic_string<char>' and 'int')
   57 |     if(A+B+C+D==7){ans=to_string(A)+'+'+to_string(C)+'+'+to_string(C)+'+'+to_string(D)+'=7';}
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
      |                                                                          |             |
      |                                                                          |             int
      |                                                                          std::__cxx11::basic_string<char>
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)'
  627 |     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:627:5: note:   template argument deduction/substitution failed:
a.cc:57:88: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
   57 |     if(A+B+C+D==7){ans=to_string(A)+'+'+to_string(C)+'+'+to_string(C)+'+'+to_string(D)+'=7';}
      |                                                                                        ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)'
 1798 |     operator+(typename move_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note:   template argument deduction/substitution failed:
a.cc:57:88: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
   57 |     if(A+B+C+D==7){ans=to_string(A)+'+'+to_string(C)+'+'+to_string(C)+'+'+to_string(D)+'=7';}
      |                                                                                        ^~~~
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3598 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3598:5: note:   template argument deduction/substitution failed:
a.cc:57:88: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
   57 |     if(A+B+C+D==7){ans=to_string(A)+'+'+to_string(C)+'+'+to_string(C)+'+'+to_string(D)+'=7';}
      |                                                                                        ^~~~
/usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3616 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3616:5: note:   template argument deduction/substitution failed:
a.cc:57:88: note:   mismatched types 'const _CharT*' and 'std::__cxx11::basic_string<char>'
   57 |     if(A+B+C+D==7){ans=to_string(A)+'+'+to_string(C)+'+'+to_string(C)+'+'+to_string(D)+'=7';}
      |                                                                                        ^~~~
/usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3635 |     operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3635:5: note:   template argument deduction/substitution failed:
a.cc:57:88: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
   57 |     if(A+B+C+D==7){ans=to_string(A)+'+'+to_string(C)+'+'+to_string(C)+'+'+to_string(D)+'=7';}
      |                                                                                        ^~~~
/usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
 3652 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3652:5: note:   template argument deduction/substitution failed:
a.cc:57:88: note:   mismatched types 'const _CharT*' and 'int'
   57 |     if(A+B+C+D==7){ans=to_string(A)+'+'+to_string(C)+'+'+to_string(C)+'+'+to_string(D)+'=7';}
      |                                                                                        ^~~~
/usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
 3670 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3670:5: note:   template argument deduction/substitution failed:
a.cc:57:88: note:   deduced conflicting types for parameter '_CharT' ('char' and 'int')
   57 |     if(A+B+C+D==7){ans=to_string(A)+'+'+to_string(C)+'+'+to_string(C)+'+'+to_string(D)+'=7';}
      |                                                                                        ^~~~
/usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3682 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3682:5: note:   template argument deduction/substitution failed:
a.cc:57:88: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
   57 |     if(A+B+C+D==7){ans=to_string(A)+'+'+to_string(C)+'+'+to_string(C)+'+'+to_string(D)+'=7';}
      |                                                                                        ^~~~
/usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3689 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3689:5: note:   template argument deduction/substitution failed:
a.cc:57:88: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
   57 |     if(A+B+C+D==7){ans=to_string(A)+'+'+to_string(C)+'+'+to_string(C)+'+'+to_string(D)+'=7';}
      |                                                                                        ^~~~
/usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class