criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
int main(){
int a[4],p[4]={0};
rep(i,4)cin>>a[i];
if(a[0]+a[1]+a[2]+a[3]==7){
  printf("%d+%d+%d+%d=7",a[0],a[1],a[2],a[3]);
 return 0;
}
if(a[0]-a[1]+a[2]+a[3]==7){
  printf("%d-%d+%d+%d=7",a[0],a[1],a[2],a[3]);
  return 0;
}
if(a[0]+a[1]-a[2]+a[3]==7){
  printf("%d+%d-%d+%d=7",a[0],a[1],a[2],a[3]);
  return 0;
}
if(a[0]+a[1]+a[2]-a[3]==7){
  printf("%d+%d+%d-%d=7",a[0],a[1],a[2],a[3]);
return 0;
}
if(a[0]+a[1]-a[2]-a[3]==7){
  printf("%d+%d-%d-%d=7",a[0],a[1],a[2],a[3]);
return 0;
}
if(a[0]-a[1]+a[2]-a[3]==7){
  printf("%d-%d+%d-%d=7",a[0],a[1],a[2],a[3]);
return 0;
}
if(a[0]-a[1]-a[2]+a[3]==7){
  printf("%d-%d-%d+%d=7",a[0],a[1],a[2],a[3]);
  return 0;
}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: 'i' was not declared in this scope
    6 | rep(i,4)cin>>a[i];
      |     ^
a.cc:3:22: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(i=0;i<n;i++)
      |                      ^
Language: C++

#include <iostream>
using namespace std;
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  char op1, op2, op3;
  for(int i = 0; i <= 1; i++) {
    for(int j = 0; j <= 1; j++) {
      for(int k = 0; k <= 1; k++) {
        if(i == 0) {
          op1 = '+';
          ans = a + b;
        }else {
          op1 = '-';
          ans = a - b;
        }
        if(j == 0) {
          op2 = '+';
          ans += c;
        }else {
          op2 = '-';
          ans -= c;
        }
        if(k == 0) {
          op3 = '+';
          ans += d;
        }else {
          op3 = '-';
          ans -= d;
        }

        if(ans == 7) {
          cout << a << op1 << b << op2 << c << op3 << d << "=" << 7;
          return 0;
        }
      }
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   13 |           ans = a + b;
      |           ^~~
      |           abs
a.cc:16:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |           ans = a - b;
      |           ^~~
      |           abs
a.cc:20:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   20 |           ans += c;
      |           ^~~
      |           abs
a.cc:23:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |           ans -= c;
      |           ^~~
      |           abs
a.cc:27:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |           ans += d;
      |           ^~~
      |           abs
a.cc:30:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |           ans -= d;
      |           ^~~
      |           abs
a.cc:33:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   33 |         if(ans == 7) {
      |            ^~~
      |            abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
string S;
bool dfs(int sum,int d,vector<char>ans(3)){
  if(d>S.size()-1){
    return true;
  }
  
if(dfs(sum+S[d],d+1,ans)){
  ans[d-1]='+';
  
  return true;
}
  if(dfs(sum-S[d],d+1,ans)){
    ans[d-1]='-';
    return true;
  }
}

int main(){
  cin>>S;
  cout<<S[0];
 if(dfs(S[0],1,ans)){
   for(int i=0;i<3;i++){
     cout<<ans[i]<<S[i+1];
   }
 }
}



Compiler output:
a.cc:4:39: error: expected ',' or '...' before '(' token
    4 | bool dfs(int sum,int d,vector<char>ans(3)){
      |                                       ^
a.cc: In function 'int main()':
a.cc:23:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |  if(dfs(S[0],1,ans)){
      |                ^~~
      |                abs
a.cc: In function 'bool dfs(int, int, std::vector<char>)':
a.cc:18:1: warning: control reaches end of non-void function [-Wreturn-type]
   18 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
string S;
bool dfs(int sum,int d,vector<char>ans(3)){
  if(d>S.size()-1){
    return true;
  }
  
if(dfs(sum+S[d],d+1,ans))
  ans[d-1]='+';
  
  return true;
}
  if(dfs(sum-S[d],d+1,ans)){
    ans[d-1]='-';
    return true;
  }
}

int main(){
  cin>>S;
  cout<<S[0];
 if(dfs(S[0],1,ans)){
   for(int i=0;i<3;i++){
     cout<<ans[i]<<S[i+1];
   }
 }
}



Compiler output:
a.cc:4:39: error: expected ',' or '...' before '(' token
    4 | bool dfs(int sum,int d,vector<char>ans(3)){
      |                                       ^
a.cc:14:3: error: expected unqualified-id before 'if'
   14 |   if(dfs(sum-S[d],d+1,ans)){
      |   ^~
a.cc:18:1: error: expected declaration before '}' token
   18 | }
      | ^
a.cc: In function 'int main()':
a.cc:23:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |  if(dfs(S[0],1,ans)){
      |                ^~~
      |                abs
Language: C++

#include<bits.stdc++.h>
using namespace std;
char s [5];
int main ()
{
scanf ("% s " ,& s );
int a = s [0] - ’0 ’ , b = s [1] - ’0 ’ , c = s [2] - ’0 ’ , d = s [3] - ’0 ’;
if (a -b -c - d ==7) printf ("% d -% d -% d -% d =7\ n " ,a ,b ,c , d );
else if (a -b - c + d ==7) printf ("% d -% d -% d +% d =7\ n " ,a ,b ,c , d );
else if (a - b +c - d ==7) printf ("% d -% d +% d -% d =7\ n " ,a ,b ,c , d );
else if (a - b + c + d ==7) printf ("% d -% d +% d +% d =7\ n " ,a ,b ,c , d );
else if ( a +b -c - d ==7) printf ("% d +% d -% d -% d =7\ n " ,a ,b ,c , d );
else if ( a +b - c + d ==7) printf ("% d +% d -% d +% d =7\ n " ,a ,b ,c , d );
else if ( a + b +c - d ==7) printf ("% d +% d +% d -% d =7\ n " ,a ,b ,c , d );
else if ( a + b + c + d ==7) printf ("% d +% d +% d +% d =7\ n " ,a ,b ,c , d );
}

Compiler output:
a.cc:1:9: fatal error: bits.stdc++.h: No such file or directory
    1 | #include<bits.stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

# coding: utf-8
ll = list(map(int, list(input())))
pm = ["+", "-"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = ll[0] + ll[1]*(-1)**i + ll[2]*(-1)**j + ll[3]*(-1)**k
            # print(ans)
            # print(ll[0], pm[i], ll[1], pm[j], ll[2], pm[k], ll[3])
            if ans == 7:
                print("{}{}{}{}{}{}{}=7".format(ll[0], pm[i], ll[1], pm[j], ll[2], pm[k], ll[3]))
                exit()

Compiler output:
a.cc:1:3: error: invalid preprocessing directive #coding
    1 | # coding: utf-8
      |   ^~~~~~
a.cc:8:15: error: invalid preprocessing directive #print
    8 |             # print(ans)
      |               ^~~~~
a.cc:9:15: error: invalid preprocessing directive #print
    9 |             # print(ll[0], pm[i], ll[1], pm[j], ll[2], pm[k], ll[3])
      |               ^~~~~
a.cc:2:1: error: 'll' does not name a type
    2 | ll = list(map(int, list(input())))
      | ^~
Language: C++

#include<iostream>
#include<cstdio>
#include<string.h>

using namespace std;

typedef long long ll;
typedef pair<int,int>P;

#define F first
#define S second

int main(){
  string s;
  char sign[3];
  int a[4];
  int temp;
  cin>>s;
  
  for(int i=0;i<4;i++){
    a[i]=s[i]-'0';
  }

  for(int i=0;i<8;i++){
    temp=a[0];
    for(int j=0;j<3;j++){
      if((i>>j)%2) sign[j]='-';
      else sign[j]='+';
    }

    for(int j=0;j<3;j++){
      if(sign[j]=='+') temp+=a[j+1];
      else temp-=a[j+1];
    }
    if(temp==7){
      printf("%d",a[0]);
      for(int j=0;j<3;j++){
	printf("%c%d",sign[j],a[j+1]);
      }
      printf("=7\n",);
      break;
    }
  }
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:21: error: expected primary-expression before ')' token
   40 |       printf("=7\n",);
      |                     ^
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
vector<string> bit;
 
 
void subBin(string str, int n)
{
    if (n == 0){
        bit.push_back(str);
    }
    if (n > 0) {
        subBin(str + "0", n - 1);
        subBin(str + "1", n - 1);
    }
}
 
string toBin(int n){
    if(n == 1)return "1";
    else if(n == 0)return "0";
 
    return toBin(n/2)  + to_string(n%2);
}
 
int main(){
    int abcd;
    cin >> abcd;
    
    int a = abcd / 1000;
    int b = (abcd % 1000)/100;
    int c = (abcd  % 100)/10;
    int d = abcd %10;
 
    rep(i, 8){
        string str = toBin(i);
        if(str.size() < 3){
            rep(j, 4 - str.size())str = "0" + str;
        }
        string ans = to_string(a);
        int isseven = a;
        if(str[0] == '1'){
            isseven += b;
            ans = ans + "+" + to_string(b);
        }
        else{
            isseven -= b;
            ans = ans + "-" + to_string(b);
        }
        if(str[1] == '1'){
            isseven += c;
            ans = ans + "+" + to_string(c);
        }
        else{
            isseven -= c;
            ans = ans + "-" + to_string(c);
        }
        if(str[2] == '1'){
            isseven += d;
            ans = ans + "+" + to_string(d);
        }
        else{
            isseven -= d;
            ans = ans + "-" + to_string(d);
        }
        if(isseven == 7){
            cout << ans + "=7";
            return 0;
        }
    }


Compiler output:
a.cc: In function 'int main()':
a.cc:75:6: error: expected '}' at end of input
   75 |     }
      |      ^
a.cc:31:11: note: to match this '{'
   31 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int A,B,C,D;
  char a,b,c,d;
  cin >> a >> b >> c >> d;
  A=a-'0';
  B=b-'0';
  C=c-'0';
  D=d-'0';
  char q,w,e;
  for(int i=0;i<9;i++){
    int sum=A;
    if(i%2==0){
      q='+';
      sum+=B;
    }
    else{
      sum-=B;
      q='-';
    }
    if((i/2)%2==0){
      sum+=C;
      w='+';
    }
    else{
      sum-=C;
      w='-';
    }
    if((i/4)%2==0){
      sum+=D;
      e='+';
    }
    else{
      sum-=D;
      e='-';
    }
    if(sum==7){
      cou << A << q << B << w << C << e << D <<"-7";
      break;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:7: error: 'cou' was not declared in this scope; did you mean 'cos'?
   40 |       cou << A << q << B << w << C << e << D <<"-7";
      |       ^~~
      |       cos
a.cc:43:2: error: expected '}' at end of input
   43 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main () {
  char a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int A, B, C, D;
  A = a - '0';
  B = b - '0';
  C = c - '0';
  D = d - '0';
  
  char op1, op2, op3;
  bool iserror = false;
  if (A + B + C + D == 7) {
    op1 = '+';
    op2 = '+';
    op3 = '+';
  }
  else if (A + B + C - D == 7) {
    op1 = '+';
    op2 = '+';
    op3 = '-';
  }
  else if (A + B - C + D == 7){
	op1 = '+';
    op2 = '-';
    op3 = '+';
  }
  else if (A + B - C - D == 7) {
    op1 = '+';
    op2 = '-';
    op3 = '-';
  }
  else if (A - B + C + D == 7)  {
    op1 = '-';
    op2 = '+';
    op3 = '+';
  }
  else if (A - B + C - D == 7) {
	op1 = '-';
    op2 = '+';
    op3 = '-';
  }
  else if (A - B - C + D == 7) {
    op1 = '-';
    op2 = '-';
    op3 = '+';
  }
  else if (A - B - C - D == 7) {
    op1 = '-';
    op2 = '-';
    op3 = '-';
  }
  else {
	cout << "error" << endl;
    iferror = true;
  }

  if (!iserror) {
    cout << A << op1 << B << op2 << C << op3 << D << "=7" << endl;
  }
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:5: error: 'iferror' was not declared in this scope; did you mean 'iserror'?
   58 |     iferror = true;
      |     ^~~~~~~
      |     iserror
Language: C++

#include<iostream>

using namespace std;

int main(){
  string n;
  for(int i=0;i<4;i++){
  cin>>n[i];
  }
 if(n[0]+n[1]+n[2]+n[3]==7)
   cout<<n[0]+n[1]+n[2]+n[3]=7<<endl;
 else if(n[0]+n[1]+n[2]-n[3]==7)
   cout<<n[0]+n[1]+n[2]-n[3]=7<<endl;
 else if(n[0]+n[1]-n[2]+n[3]==7)
   cout<<n[0]+n[1]-n[2]+n[3]=7<<endl;
 else if(n[0]+n[1]-n[2]-n[3]==7)
   cout<<n[0]+n[1]-n[2]-n[3]=7<<endl;
 else if(n[0]-n[1]+n[2]+n[3]==7)
   cout<<n[0]-n[1]+n[2]+n[3]=7<<endl;
 else if(n[0]-n[1]+n[2]-n[3]==7)
   cout<<n[0]-n[1]+n[2]-n[3]=7<<endl;
 else if(n[0]-n[1]-n[2]+n[3]==7)
   cout<<n[0]-n[1]-n[2]+n[3]=7<<endl;
 else if(n[0]-n[1]-n[2]-n[3]==7)
   cout<<n[0]-n[1]-n[2]-n[3]=7<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:31: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   11 |    cout<<n[0]+n[1]+n[2]+n[3]=7<<endl;
      |                              ~^~~~~~
a.cc:13:31: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   13 |    cout<<n[0]+n[1]+n[2]-n[3]=7<<endl;
      |                              ~^~~~~~
a.cc:15:31: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   15 |    cout<<n[0]+n[1]-n[2]+n[3]=7<<endl;
      |                              ~^~~~~~
a.cc:17:31: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   17 |    cout<<n[0]+n[1]-n[2]-n[3]=7<<endl;
      |                              ~^~~~~~
a.cc:19:31: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   19 |    cout<<n[0]-n[1]+n[2]+n[3]=7<<endl;
      |                              ~^~~~~~
a.cc:21:31: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   21 |    cout<<n[0]-n[1]+n[2]-n[3]=7<<endl;
      |                              ~^~~~~~
a.cc:23:31: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   23 |    cout<<n[0]-n[1]-n[2]+n[3]=7<<endl;
      |                              ~^~~~~~
a.cc:25:31: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   25 |    cout<<n[0]-n[1]-n[2]-n[3]=7<<endl;
      |                              ~^~~~~~
Language: C++

#include<iostream>

using namespace std;

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

    if(A+B+C+D=7){
          cout<<A<<'+'<<B<<'+'<<C<<'+'<<D<<'='<<7<<endl;
    }else if(A-B+C+D==7){
        cout<<A<<'-'<<B<<'+'<<C<<'+'<<D<<'='<<7<<endl;
    }else if(A+B-C+D==7){
        cout<<A<<'+'<<B<<'-'<<C<<'+'<<D<<'='<<7<<endl;
    }else if(A+B+C-D==7){
        cout<<A<<'+'<<B<<'+'<<C<<'-'<<D<<'='<<7<<endl;
    }else if(A-B-C+D==7){
        cout<<A<<'-'<<B<<'-'<<C<<'+'<<D<<'='<<7<<endl;
    }else if(A+B-C-D==7){
        cout<<A<<'+'<<B<<'-'<<C<<'-'<<D<<'='<<7<<endl;
    }else if(A-B+C-D==7){
        cout<<A<<'-'<<B<<'+'<<C<<'-'<<D<<'='<<7<<endl;
    }else if(A-B-C-D==7){
        cout<<A<<'-'<<B<<'-'<<C<<'-'<<D<<'='<<7<<endl;
    }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:13: error: lvalue required as left operand of assignment
    9 |     if(A+B+C+D=7){
      |        ~~~~~^~
Language: C++

#include<iostream>

using namespace std;

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

    if(A+B+C+D=7){
          cout<<A<<'+'<<B<<'+'<<C<<'+'<<D<<'='<<7<<endl;
    }else if(A-B+C+D=7){
        cout<<A<<'-'<<B<<'+'<<C<<'+'<<D<<'='<<7<<endl;
    }else if(A+B-C+D=7){
        cout<<A<<'+'<<B<<'-'<<C<<'+'<<D<<'='<<7<<endl;
    }else if(A+B+C-D=7){
        cout<<A<<'+'<<B<<'+'<<C<<'-'<<D<<'='<<7<<endl;
    }else if(A-B-C+D=7){
        cout<<A<<'-'<<B<<'-'<<C<<'+'<<D<<'='<<7<<endl;
    }else if(A+B-C-D=7){
        cout<<A<<'+'<<B<<'-'<<C<<'-'<<D<<'='<<7<<endl;
    }else if(A-B+C-D=7){
        cout<<A<<'-'<<B<<'+'<<C<<'-'<<D<<'='<<7<<endl;
    }else if(A-B-C-D=7){
        cout<<A<<'-'<<B<<'-'<<C<<'-'<<D<<'='<<7<<endl;
    }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:13: error: lvalue required as left operand of assignment
    9 |     if(A+B+C+D=7){
      |        ~~~~~^~
a.cc:11:19: error: lvalue required as left operand of assignment
   11 |     }else if(A-B+C+D=7){
      |              ~~~~~^~
a.cc:13:19: error: lvalue required as left operand of assignment
   13 |     }else if(A+B-C+D=7){
      |              ~~~~~^~
a.cc:15:19: error: lvalue required as left operand of assignment
   15 |     }else if(A+B+C-D=7){
      |              ~~~~~^~
a.cc:17:19: error: lvalue required as left operand of assignment
   17 |     }else if(A-B-C+D=7){
      |              ~~~~~^~
a.cc:19:19: error: lvalue required as left operand of assignment
   19 |     }else if(A+B-C-D=7){
      |              ~~~~~^~
a.cc:21:19: error: lvalue required as left operand of assignment
   21 |     }else if(A-B+C-D=7){
      |              ~~~~~^~
a.cc:23:19: error: lvalue required as left operand of assignment
   23 |     }else if(A-B-C-D=7){
      |              ~~~~~^~
Language: C++

#include<iostream>

using namespace std;

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

    if(A+B+C+D=7){
          cout<<A<<'+'<<B<<'+'<<C<<'+'<<D<<'='<<7<<endl;
    }else if(A-B+C+D=7){
        cout<<A<<'-'<<B<<'+'<<C<<'+'<<D<<'='<<7<<endl;
    }else if(A+B-C+D=7){
        cout<<A<<'+'<<B<<'-'<<C<<'+'<<D<<'='<<7<<endl;
    }else if(A+B+C-D=7){
        cout<<A<<'+'<<B<<'+'<<C<<'-'<<D<<'='<<7<<endl;
    }else if(A-B-C+D=7){
        cout<<A<<'-'<<B<<'-'<<C<<'+'<<D<<'='<<7<<endl;
    }else if(A+B-C-D=7){
        cout<<A<<'+'<<B<<'-'<<C<<'-'<<D<<'='<<7<<endl;
    }else if(A-B+C-D=7){
        cout<<A<<'-'<<B<<'+'<<C<<'-'<<D<<'='<<7<<endl;
    }else if(A-B-C-D=7){
        cout<<A<<'-'<<B<<'-'<<C<<'-'<<D<<'='<<7<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:13: error: lvalue required as left operand of assignment
    9 |     if(A+B+C+D=7){
      |        ~~~~~^~
a.cc:11:19: error: lvalue required as left operand of assignment
   11 |     }else if(A-B+C+D=7){
      |              ~~~~~^~
a.cc:13:19: error: lvalue required as left operand of assignment
   13 |     }else if(A+B-C+D=7){
      |              ~~~~~^~
a.cc:15:19: error: lvalue required as left operand of assignment
   15 |     }else if(A+B+C-D=7){
      |              ~~~~~^~
a.cc:17:19: error: lvalue required as left operand of assignment
   17 |     }else if(A-B-C+D=7){
      |              ~~~~~^~
a.cc:19:19: error: lvalue required as left operand of assignment
   19 |     }else if(A+B-C-D=7){
      |              ~~~~~^~
a.cc:21:19: error: lvalue required as left operand of assignment
   21 |     }else if(A-B+C-D=7){
      |              ~~~~~^~
a.cc:23:19: error: lvalue required as left operand of assignment
   23 |     }else if(A-B-C-D=7){
      |              ~~~~~^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  int v[3];
  int a = s[0] - '0';
  v[0] = s[1] - '0';
  v[1] = s[2] - '0';
  v[2] = s[3] - '0';
  for(int i = 0; i < 8; i++){
    int r = a;
  	for(int j = 0; j < 3; j++)
      if(i&(1<<j)) r -= v[j];
    	else r += v[j];
    if(r == 7){
      cout << a;
      for(int j = 0; j < 3; j++){
      	if(i&(1<<j)) cout << "-";
        else cout << "+";
        cout << v[j];
      }
      cout << "=7" << endl;
      return 0;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:2: error: expected '}' at end of input
   26 | }
      |  ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=0;i<b;i++)
#define REP(i,a,b) for(int i=0;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;


signed main(){
    int num;
    cin >> num;
    vi abc(4);
    rep(i,4)
    {
        abc[i]=num%10;
        num/=10;
    }
    reverse(all(abc));
    int a,b,c,d;
    a=abc[0];
    b=abc[1];
    c=abc[2];
    d=abc[3];
    int opt1,opt2,opt3;
    opt1=opt2=opt3=1;

    rep(i,2)
    {
        rep(j,2)
        {
            rep(k,2)
            {
                if(k==0)opt1=1;
                else opt1=-1;
                if(j==0)opt2=1;
                else opt2=-1;
                if(i==0)opt3=1;
                else opt2=-1;
                if(a+b*opt1+c*opt2+d*opt3==7)
                {
                    char one,two,three;
                    if(opt1==-1)one='-';
                    else one='+';
                    if(opt2==-1)two='-';
                    else two='+';
                    if(opt3==-1)three='-';
                    else three='+';
                    cout << a << one << b << two << c << three << d << "=7";
                    return;
                }
            }
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:21: error: return-statement with no value, in function returning 'int' [-fpermissive]
   70 |                     return;
      |                     ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;

int main(){
  int N; cin >> N;
  int d,e,f;
  for(int a=1;a<=2;a++){
    for(int b=1;b<=2;b++){
      for(int c=1;c<=2;c++){
       if((N.at(0)+(-1)*a*N.at(1)+(-1)*b*N.at(2)+(-1)*c*N.at(3)) == 7)
       {d = a; e = b; f = c;}
      }
    }
  }
  cout << N.at(0) << flush;
  if(d-1){cout << "+" << N.at(1) << flush;}
  else{cout << "-" << N.at(1) << flush;}
  if(e-1){cout << "+" << N.at(2) << flush;}
  else{cout << "-" << N.at(2) << flush;}
  if(f-1){cout << "+" << N.at(3) << flush;}
  else{cout << "-" << N.at(3) << flush;}
  cout << "=" << 7 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:14: error: request for member 'at' in 'N', which is of non-class type 'int'
   10 |        if((N.at(0)+(-1)*a*N.at(1)+(-1)*b*N.at(2)+(-1)*c*N.at(3)) == 7)
      |              ^~
a.cc:10:29: error: request for member 'at' in 'N', which is of non-class type 'int'
   10 |        if((N.at(0)+(-1)*a*N.at(1)+(-1)*b*N.at(2)+(-1)*c*N.at(3)) == 7)
      |                             ^~
a.cc:10:44: error: request for member 'at' in 'N', which is of non-class type 'int'
   10 |        if((N.at(0)+(-1)*a*N.at(1)+(-1)*b*N.at(2)+(-1)*c*N.at(3)) == 7)
      |                                            ^~
a.cc:10:59: error: request for member 'at' in 'N', which is of non-class type 'int'
   10 |        if((N.at(0)+(-1)*a*N.at(1)+(-1)*b*N.at(2)+(-1)*c*N.at(3)) == 7)
      |                                                           ^~
a.cc:15:13: error: request for member 'at' in 'N', which is of non-class type 'int'
   15 |   cout << N.at(0) << flush;
      |             ^~
a.cc:16:28: error: request for member 'at' in 'N', which is of non-class type 'int'
   16 |   if(d-1){cout << "+" << N.at(1) << flush;}
      |                            ^~
a.cc:17:25: error: request for member 'at' in 'N', which is of non-class type 'int'
   17 |   else{cout << "-" << N.at(1) << flush;}
      |                         ^~
a.cc:18:28: error: request for member 'at' in 'N', which is of non-class type 'int'
   18 |   if(e-1){cout << "+" << N.at(2) << flush;}
      |                            ^~
a.cc:19:25: error: request for member 'at' in 'N', which is of non-class type 'int'
   19 |   else{cout << "-" << N.at(2) << flush;}
      |                         ^~
a.cc:20:28: error: request for member 'at' in 'N', which is of non-class type 'int'
   20 |   if(f-1){cout << "+" << N.at(3) << flush;}
      |                            ^~
a.cc:21:25: error: request for member 'at' in 'N', which is of non-class type 'int'
   21 |   else{cout << "-" << N.at(3) << flush;}
      |                         ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;

int main(){
  int N; cin >> N;
  int T = N;
  vector<int> A(N);
  for(int i=0;i<4;i++){
    A[i] = T%10;
    T /= 10;
  }
  int d,e,f;
  for(int a=1;a<=2;a++){
    for(int b=1;b<=2;b++){
      for(int c=1;c<=2;c++){
       if((A[3]+(-1)*a*A[2]+(-1)*b*A[1]+(-1)*c*A[0])=7)
       {d = a; e = b; f = c;}
      }
    }
  }
  cout << A[3] << flush;
  if(d-1){cout << "+" << A[2] << flush;}
  else{cout << "-" << A[2] << flush;}
  if(e-1){cout << "+" << A[1] << flush;}
  else{cout << "-" << A[1] << flush;}
  if(f-1){cout << "+" << A[0] << flush;}
  else{cout << "-" << A[0] << flush;}
  cout << "=" << 7 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:40: error: lvalue required as left operand of assignment
   16 |        if((A[3]+(-1)*a*A[2]+(-1)*b*A[1]+(-1)*c*A[0])=7)
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
Language: C

/*
char s[5];
scanf("%s",s);
int l;
l = strlen(s);
int d[5],i,j;
char ans[10];
REP(i,4)
{
	d[i] = s[i] - '0';
	ans[2*i] = s[i];
}
ans[7] = '=';
の様にしていたがうまくいかなかった。
*/
#include<stdio.h>
#define REP(i,n) for(i=0;i<n;i++)
int main(void)
{
	char a,b,c,d;
	scanf("%c%c%c%c",&a,&b,&c,%d);
	int i;
	REP(i,8)//可変であればbit探索
	{
		ll ans = a-'0';//ASCII code
		ans += ((i>>0)&1)? b-'0':'0'-b;
		ans += ((i>>1)&1)? c-'0':'0'-d;
		ans += ((i>>2)&1)? d-'0':'0'-d;
		if(ans==7)
		{
			printf("%c%c%c%c%c%c%c=7\n",a,((i>>0)&1)? '+':'-',b,(i>>1)&1)? '+':'-',c,(i>>0)&2)? '+':'-',d);
			
		}
	}
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:21:35: error: expected expression before '%' token
   21 |         scanf("%c%c%c%c",&a,&b,&c,%d);
      |                                   ^
main.c:25:17: error: unknown type name 'll'
   25 |                 ll ans = a-'0';//ASCII code
      |                 ^~
main.c:31:106: error: expected ';' before ')' token
   31 |                         printf("%c%c%c%c%c%c%c=7\n",a,((i>>0)&1)? '+':'-',b,(i>>1)&1)? '+':'-',c,(i>>0)&2)? '+':'-',d);
      |                                                                                                          ^
      |                                                                                                          ;
main.c:31:106: error: expected statement before ')' token
main.c:31:107: error: expected expression before '?' token
   31 |                         printf("%c%c%c%c%c%c%c=7\n",a,((i>>0)&1)? '+':'-',b,(i>>1)&1)? '+':'-',c,(i>>0)&2)? '+':'-',d);
      |                                                                                                           ^
main.c:31:118: error: expected statement before ')' token
   31 |                         printf("%c%c%c%c%c%c%c=7\n",a,((i>>0)&1)? '+':'-',b,(i>>1)&1)? '+':'-',c,(i>>0)&2)? '+':'-',d);
      |                                                                                                                      ^
Language: C++

#include <bits/stdc++.h>

int a, b, c, d;

int main() {
  std::cin >> a >> b >> c >> d;
  for (int i = 0; i <=1; i++) {
    for (int j = 0; j<=1; j++) {
      for (int k = 0; k <= 1; k++) {
        if (i == 1) {
          b *= -1;
        }
        if (j == 1) {
          c *= -1;
        }
        if (k == 1) {
          d *= -1;
        }
        if (a+b+c+d == 7) {
          std::cout << a;
          std::cout << std::showpos << b;
          std::cout << std::showpos << c;
          std::cout << std::showpos << d;
          std::cout << "=7" << std::endl;
      }
    }
  }     
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:2: error: expected '}' at end of input
   28 | }
      |  ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
int main() {
  string s;
  cin >> s;
  int a[4],b[2]={1,-1};
  char c[2]={'+','-'};
  for(int i=0; i<4; i++) {
    a[i]=s[i]-'0';
  }
  for(int i=0; i<2; i++) {
    for(int j=0; j<2; j++) {
      for(int k=0; k<2; k++) {
        if(a[0]+a[1]*b[i]+a[2]*b[j]+a[3]*b[k]==7) {
          cout <<s[0]<<c[i]<<s[1]<<c[j]<<s[2]<<c[k]<<s[3]<<"=7"<<endl;
          return 0;
        }
      }
    }
  }
}
}

Compiler output:
a.cc:26:1: error: expected declaration before '}' token
   26 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;

int main() {
  string s; cin >> s;
  int a = s[0] - '0';
  int b = s[1] - '0';
  int c = s[2] - '0';
  int d = s[3] - '0';

  char op[] = {'+', '-'};

  for(int i = 0; i < 2; i++) {
      for(int j = 0; j < 2; j++) {
          for(int k = 0; k < 2; k++) {
              ans = a;
              if(op[i] == '+') ans += b;
              if(op[i] == '-') ans -= b;
              if(op[j] == '+') ans += c;
              if(op[j] == '-') ans -= c;
              if(op[k] == '+') ans += d;
              if(op[k] == '-') ans -= d;
              if(ans == 7) {
                  cout << a << op[i] << b << op[j] << c << op[k] << d << "=7" << endl;
                  return 0;
              }
          }
      }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   17 |               ans = a;
      |               ^~~
      |               abs
Language: C++

#include <iostream>
#include <vector>
using namespace std;

int main() {
    string s; cin >> s;
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';

    char op[] = {'+', '-'};

    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < 2; j++) {
            for(int k = 0; k < 2; k++) {
                ans = a;
                if(op[i] == '+') ans += b;
                if(op[i] == '-') ans -= b;
                if(op[j] == '+') ans += c;
                if(op[j] == '-') ans -= c;
                if(op[k] == '+') ans += d;
                if(op[k] == '-') ans -= d;
                if(ans == 7) {
                    cout << a << op[i] << b << op[j] << c << op[k] << d << endl;
                    return 0;
                }
            }
        }
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   17 |                 ans = a;
      |                 ^~~
      |                 abs
Language: C++

#include <iostream>
#include <string>
using namespace std;

int main() {
  string ABCD;
  cin >> ABCD;
  for (int i=0; i<(1<<3); ++i) {
    int sumV = stoi(str[0]);
    string ans = str[0];
    for (int j=0; j<3; ++j) {
      if (i & (1<<j)) {
        sumV += stoi(str[j+1]);
        ans += '+';
        ans += str[j+1];
      }
      else {
        sumV -= stoi(str[j+1]);
        ans += '-';
        ans += str[j+1];
      }
    }
    if (sumV == 7) {
      ans += "=7";
      cout << ans << "\n";
      return 0;
    }
  }
}

      

Compiler output:
a.cc: In function 'int main()':
a.cc:9:21: error: 'str' was not declared in this scope; did you mean 'std'?
    9 |     int sumV = stoi(str[0]);
      |                     ^~~
      |                     std
Language: C++

#include <iostream>
#include <string>
using namespace std;

int main() {
  string ABCD;
  cin >> ABCD;
  for (int i=0; i<(1<<3); ++i) {
    int sumV = stoi(integer[0]);
    string ans = str[0];
    for (int j=0; j<3; ++j) {
      if (i & (1<<j)) {
        sumV += stoi(str[j+1]);
        ans += '+';
        ans += str[j+1];
      }
      else {
        sumV -= stoi(str[j+1]);
        ans += '-';
        ans += str[j+1];
      }
    }
    if (sumV == 7) {
      ans += "=7";
      cout << ans << "\n";
      return 0;
    }
  }
}

      

Compiler output:
a.cc: In function 'int main()':
a.cc:9:21: error: 'integer' was not declared in this scope
    9 |     int sumV = stoi(integer[0]);
      |                     ^~~~~~~
a.cc:10:18: error: 'str' was not declared in this scope; did you mean 'std'?
   10 |     string ans = str[0];
      |                  ^~~
      |                  std
Language: C++

#include <iostream>
#include <string>
using namespace std;

int main() {
  int integer[4];
  for (int i=0; i<4; ++i) {
    cin >> integer[i];
  }
  for (int i=0; i<(1<<3); ++i) {
    int sumV = integer[0];
    string ans;
    for (int j=0; j<3; ++j) {
      if (i & (1<<j)) {
        sumV += integer[j+1];
        ans += '+';
        ans += to_string(integer[j+1]);
      }
      else {
        sumV -= integer[j+1];
        ans += '-';
        ans += to_string(integer[j+1]);
      }
    }
    if (sumV == 7) {
      ans += "=7";
      cout << ans << "\n";
      return;
    }
  }
}

      

Compiler output:
a.cc: In function 'int main()':
a.cc:28:7: error: return-statement with no value, in function returning 'int' [-fpermissive]
   28 |       return;
      |       ^~~~~~
Language: C++

#include <iostream>
#include <string>
using namespace std;

int main() {
  int integer[4];
  for (int i=0; i<4; ++i) {
    cin >> integer[i];
  }
  for (int i=0; i<(1<<3); ++i) {
    int sumV = A;
    string ans;
    for (int j=0; j<3; ++j) {
      if (i & (1<<j)) {
        sumV += integer[j+1];
        ans += '+';
        ans += to_string(integer[j+1]);
      }
      else {
        sumV -= integer[j+1];
        ans += '-';
        ans += to_string(integer[j+1]);
      }
    }
    if (sumV == 7) {
      ans += "=7";
      cout << ans << "\n";
      return;
    }
  }
}

      

Compiler output:
a.cc: In function 'int main()':
a.cc:11:16: error: 'A' was not declared in this scope
   11 |     int sumV = A;
      |                ^
a.cc:28:7: error: return-statement with no value, in function returning 'int' [-fpermissive]
   28 |       return;
      |       ^~~~~~
Language: Java


 日本語 
 zaki1236 (Guest) 
コンテスト時間: 2017-11-18(土) 21:00 ~ 2017-11-18(土) 22:40 AtCoderホームへ戻る
 トップ
 問題
 質問
 提出
 提出一覧
 順位表
 コードテスト
 解説
提出 #5424555

ソースコード 拡げる

Copy
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner stdIn=new Scanner(System.in);
String s=stdIn.next();
int a[]=new int[4];
char plus[]={'-','-','-'};
int z=0,y=2,sum=0;
while(z<4){
a[z]=Integer.valueOf(s.substring(z,z+1));
z++;
}z=0;
while(z<Math.pow(2,3)){
s=Integer.toBinaryString(z);
while(y<s.length()){
if(s.charAt(y)=='1')
  plus[2-y]='+';
else
  plus[2-y]='-';
y++;
}sum=a[0];y=0;
while(y<3){
if(plus[y]=='+')
  sum+=a[y+1];
else
  sum+=a[y+1];
y++;
}
if(sum==7)
  break;
  while(y<3){
  plus[y]='-';
    y++;
  }
y=0;z++;
}
System.out.println(a[0]+""+plus[0]+""+a[1]+""+plus[1]+""+a[2]+""+plus[2]+""+a[3]+"=7");
}
}

Compiler output:
Main.java:13: error: illegal character: '#'
?? #5424555
   ^
Main.java:2: error: unnamed classes are a preview feature and are disabled by default.
 ??? 
 ^
  (use --enable-preview to enable unnamed classes)
Main.java:3: error: ';' expected
 zaki1236 (Guest) 
                 ^
3 errors
Language: Java

import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner stdIn=new Scanner(System.in);
String s=stdIn.next();
int a[]=new int[4];
char plus[]={'-','-','-'};
int z=0,y=2,sum=0;
while(z<4){
a[z]=Integer.valueOf(s.substring(z,z+1));
z++;
}z=0;
while(z<Math.pow(2,3){
s=Integer.toBinaryString(z);
while(y<s.length()){
if(s.charAt(y)=='1')
  plus[2-y]='+';
else
  plus[2-y]='-';
y++;
}sum=a[0];y=0;
while(y<3){
if(plus[y]=='+')
  sum+=a[y+1];
else
  sum+=a[y+1];
y++;
}
if(sum==7)
  break;
y=0;z++;
}
System.out.println(a[0]+""+plus[0]+""+a[1]+""+plus[1]+""+a[2]+""+plus[2]+""+a[3]);
}
}

Compiler output:
Main.java:13: error: ')' expected
while(z<Math.pow(2,3){
                     ^
1 error
Language: Java

import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner stdIn=new Scanner(System.in);
String s=stdIn.next();
int a[]=new int[4];
char plus[]={'-','-','-'};
int z=0.y=2,sum=0;
while(z<4){
a[z]=Integer.valueOf(s.substring(z,z+1));
z++;
}z=0;
while(z<Math.pow(2,3){
s=Integer.toBinaryString(z);
while(y<s.length()){
if(s.charAt(y)=='1')
  plus[2-y]='+';
else
  plus[2-y]='-';
y++;
}sum=a[0];y=0;
while(y<3){
if(plus[y]=='+')
  sum+=a[y+1];
else
  sum+=a[y+1];
y++;
}
if(sum==7)
  break;
y=0;z++;
}
System.out.println(a[0]+""+plus[0]+""+a[1]+""+plus[1]+""+a[2]+""+plus[2]+""+a[3]);
}
}

Compiler output:
Main.java:8: error: ';' expected
int z=0.y=2,sum=0;
        ^
Main.java:8: error: ';' expected
int z=0.y=2,sum=0;
           ^
Main.java:13: error: ')' expected
while(z<Math.pow(2,3){
                     ^
3 errors
Language: Java

import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		for(int i = 0;i<Math.pow(2, 3);i++) {
			StringBuilder sb = new StringBuilder(S);
			boolean plus = true;
			int judge = 0;


			for(int j = 2;j>=0;j--) {
				if((1&i>>j)==1) {
					sb.insert(j+1, "+");
				}else {
					sb.insert(j+1, "-");
				}
			}

			String str = sb.toString();

			for(int n = 0;n<7;n++) {

				char st =str.charAt(n);

				if(n==0) {
					judge+= Character.getNumericValue(st);
					continue;
				}else if(n%2==0) {
					if(plus==true) {
					judge+= Character.getNumericValue(st);
					}else {
					judge-= Character.getNumericValue(st);
					}
				}else if(n%2==1) {
					if(st=='+') {
						plus=true;
					}else {
						plus =  false;
					}
				}


			}
			if(judge==7) {
				System.out.println(str+"=7");
				break;

			}
			
		}
	}

Compiler output:
Main.java:57: error: reached end of file while parsing
	}
	 ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

string search8(int p,int q,int r,int s){
  string x = "";
  smp = "";
  if(p + q + r + s == 7)smp=+++;
  if(p + q + r - s == 7)smp=++-;
  if(p + q - r + s == 7)smp=+-+;
  if(p + q - r - s == 7)smp=+--;
  if(p - q + r + s == 7)smp=-++;
  if(p - q + r - s == 7)smp=-+-;
  if(p - q - r + s == 7)smp=--+;
  if(p - q - r - s == 7)smp=---;
  
  x+=to_string(p);
  x+=smp.at(0);
  x+=to_string(q);
  x+=smp.at(1);
  x+=to_string(r);
  x+=smp.at(2);
  x+=to_string(s);
    
  return x;
}

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  cout << search8(a,b,c,d) << endl;
}

Compiler output:
a.cc: In function 'std::string search8(int, int, int, int)':
a.cc:15:3: error: 'smp' was not declared in this scope
   15 |   smp = "";
      |   ^~~
a.cc:16:32: error: expected primary-expression before ';' token
   16 |   if(p + q + r + s == 7)smp=+++;
      |                                ^
a.cc:17:32: error: expected primary-expression before ';' token
   17 |   if(p + q + r - s == 7)smp=++-;
      |                                ^
a.cc:18:32: error: expected primary-expression before ';' token
   18 |   if(p + q - r + s == 7)smp=+-+;
      |                                ^
a.cc:19:32: error: expected primary-expression before ';' token
   19 |   if(p + q - r - s == 7)smp=+--;
      |                                ^
a.cc:20:32: error: expected primary-expression before ';' token
   20 |   if(p - q + r + s == 7)smp=-++;
      |                                ^
a.cc:21:32: error: expected primary-expression before ';' token
   21 |   if(p - q + r - s == 7)smp=-+-;
      |                                ^
a.cc:22:32: error: expected primary-expression before ';' token
   22 |   if(p - q - r + s == 7)smp=--+;
      |                                ^
a.cc:23:32: error: expected primary-expression before ';' token
   23 |   if(p - q - r - s == 7)smp=---;
      |                                ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
string a;
vector<char> b(3);
solve(int i,int sum){
    if(i==4) return (sum==7-(a.at(0)-'0'));
    if (solve(i+1,sum+=a.at(i)-'0')) {b.at(i-1)='+'; return true;}
    if(solve(i+1,sum-=a.at(i)-'0')) {b.at(i-1)='-';return true;}
    return false;
}
int main(){
    cin>>a;
    solve(1,0);
    cout<<a.at(0);
    for(int i=1;i<4;i++) cout<<b.at(i-1)<<a.at(i);
    cout<<"=7"<<endl;
}

Compiler output:
a.cc:6:1: error: ISO C++ forbids declaration of 'solve' with no type [-fpermissive]
    6 | solve(int i,int sum){
      | ^~~~~
Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(void){
	std::string s,c1,c2,c3;
  	cin >> s;
  	int a,b,c,d,i,sum;
  	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: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;
      |                                                                    ~             ^
      |                                                                                  )
Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(void){
	std::string s,c1,c2,c3;
  	cin >> s;
  	int a,b,c,d,i,sum;
  	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: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;
      |                                                                    ~             ^
      |                                                                                  )
Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(void){
	std::string s;
  	cin >> s;
  	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:15:25: error: expected ';' before ')' token
   15 |         for (i=0;i<8,i++){
      |                         ^
      |                         ;
a.cc:16:82: error: expected ')' before ';' token
   16 |         sum = a + (int)(pow(-1,i))*b + (int)(pow(-1,i%2))*c + (int)(pow(-1,i%3)*d;
      |                                                                    ~             ^
      |                                                                                  )
a.cc:19:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   19 |                 c1 = "+";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:21:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   21 |                 c1 = "-";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:24:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   24 |                 c2 = "+";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:26:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   26 |                 c2 = "-";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:29:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   29 |                 c3 = "+";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:31:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   31 |                 c3 = "-";
      |                      ^~~
      |                      |
      |                      const char*
Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(void){
	std::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:7:25: error: expected initializer before ':' token
    7 |         std::string s[4]:
      |                         ^
a.cc:11:18: error: 's' was not declared in this scope
   11 |         a = stoi(s.substr(0,1));
      |                  ^
a.cc:15:25: error: expected ';' before ')' token
   15 |         for (i=0;i<8,i++){
      |                         ^
      |                         ;
a.cc:16:82: error: expected ')' before ';' token
   16 |         sum = a + (int)(pow(-1,i))*b + (int)(pow(-1,i%2))*c + (int)(pow(-1,i%3)*d;
      |                                                                    ~             ^
      |                                                                                  )
a.cc:19:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   19 |                 c1 = "+";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:21:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   21 |                 c1 = "-";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:24:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   24 |                 c2 = "+";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:26:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   26 |                 c2 = "-";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:29:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   29 |                 c3 = "+";
      |                      ^~~
      |                      |
      |                      const char*
a.cc:31:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   31 |                 c3 = "-";
      |                      ^~~
      |                      |
      |                      const char*