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

#include <string>
#include <cctype>
#include <iostream>
typedef std::string::iterator State;
using namespace std;

 
int number(State &begin);
int factor(State &begin);
int term(State &begin);
int expression(State &begin);

int main(void){
  int N;
  std::cin >> N;

  while(N--){
    std::string s;
    std::cin>>s;
    State begin = s.begin();
    int ans = expression(begin);
    std::cout << ans << std::endl;
  }
  return 0;
}
 
int number(State &begin){
  int ret = 0;
 
  while(isdigit(*begin)){
    ret *= 10;
    ret += *begin - '0';
    begin++;
  }
 
  return ret;
}
 
int factor(State &begin){
  if(*begin == '('){
    begin++;
    int ret = expression(begin);
    begin++;
    return ret;
  }else{
    return number(begin);
  }
}
 

 
int expression(State &begin){
  int num = term(begin);
  int sum = 0;
  
  for(;;){
    char ch = *begin;
    begin++;
    if(ch == '+'){
      num += factor(begin);
    } else if(ch == '-'){
      num -= factor(begin);
    }else if(ch == '*'){
      sum += num;
      num = factor(begin);
    }else if(ch == '/'){
      sum += num;
      num = factor(begin);
    }else{
      break;
    }
  }
  return sum+num;
}

Compiler output:
/usr/bin/ld: /tmp/ccIYM2x6.o: in function `expression(__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&)':
a.cc:(.text+0x1c7): undefined reference to `term(__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&)'
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
using namespace std;

int hyoka(string);
int isNum(int);

int main(){
	int n,i;
	string s;
	
	cin>>n;
	for(i=0;i<n;i++){
	 cin>>s;
	 cout<<hyoka(s)<<endl;
	}
		
	return 0;
}


int hyoka(string s){
	long int total=0,work=0;
	long int tmp1,tmp2;
	int oi=0;
	char oc;
	int n;
	string cs;
	
	if(isNum(s[oi])==-1){s="+"+s;}
	
	while(1){
	 oc=s[oi];if(oc=='='){total+=work;break;}
	 
	 if(s[oi+1]!='('){	//??°???????????????
	  tmp1=0;
	  while(1){
	   oi++;
	   tmp2=s[oi];
	   if(tmp2!=-1){tmp1=tmp1*10+tmp2;}else{break;}
	  }
	 }else{	//??????????????°
	  cs="";n=1;oi++;
	  while{
	   oi++;
	   switch(s[oi]){
		case '(':n++;break;
		case ')':n--;break;
	   }
	   if(n!=0){cs+=s[oi];}else{break;}
	  }
	  tmp1=hyoka(cs);
	 }
	
	 switch(oc){
	  case '+':total+=work;work=tmp1;break;
	  case '-':total+=work;work=-tmp1;break;
	  case '*':work*=tmp1;break;
	  case '/':work/=tmp1;break;
	 }
	}
	
	return total;
}

int isNum(int c){
	if(49<=c && c<=57){
	 return c-49;
	}
	return -1;
}

Compiler output:
a.cc: In function 'int hyoka(std::string)':
a.cc:43:16: error: expected '(' before '{' token
   43 |           while{
      |                ^
      |                (
a.cc:43:16: error: expected primary-expression before '{' token
a.cc:43:16: error: expected ')' before '{' token
   43 |           while{
      |                ^
      |                )
Language: C++

#include <iostream>
using namespace std;

int hyoka(string);
int isNum(int);

int main(){
	int n,i;
	string s;
	
	cin>>n;
	for(i=0;i<n;i++){
	 cin>>s;
	 cout<<hyoka(s)<<endl;
	}
		
	return 0;
}


long int hyoka(string s){
	long int total=0,work=0;
	long int tmp1,tmp2;
	int oi=0;
	char oc;
	int n;
	string cs;
	
	if(isNum(s[oi])!=-1){s="+"+s;}
	
	while(1){
	 oc=s[oi];if(oc=='='){total+=work;break;}
	 
	 if(s[oi+1]!='('){	//??°???????????????
	  tmp1=0;
	  while(1){
	   oi++;
	   tmp2=s[oi];
	   if(tmp2!=-1){tmp1=tmp1*10+tmp2;}else{break;}
	  }
	 }else{	//??????????????°
	  cs="";n=1;oi++;
	  while(1){
	   oi++;
	   switch(s[oi]){
		case '(':n++;break;
		case ')':n--;break;
	   }
	   if(n!=0){cs+=s[oi];}else{break;}
	  }
	  cs+='=';
	  tmp1=hyoka(cs);
	 }
	
	 switch(oc){
	  case '+':total+=work;work=tmp1;break;
	  case '-':total+=work;work=-tmp1;break;
	  case '*':work*=tmp1;break;
	  case '/':work/=tmp1;break;
	 }
	}
	
	return total;
}

int isNum(int c){
	if(49<=c && c<=57){
	 return c-49;
	}
	return -1;
}

Compiler output:
a.cc:21:10: error: ambiguating new declaration of 'long int hyoka(std::string)'
   21 | long int hyoka(string s){
      |          ^~~~~
a.cc:4:5: note: old declaration 'int hyoka(std::string)'
    4 | int hyoka(string);
      |     ^~~~~
Language: C++

#include <iostream>
#include <string>
using namespace std;
// const string S = "(1+1)*2";
string S;
int cur = 0;
int digit();
int number();
int factor();
int term();
int _term(int m);
int exp();
int _exp(int m);
int parse();
bool isdigit(char);
bool is_plu_min(char);
bool is_tim_div(char);
int main() {
  int N;
  cin >> N;
  for (int i=0;i<N;i++) {
    cin >> S;
    cur = 0;
    S.resize(S.size()-1);
    cout << parse() << endl;
  }
  return 0;
}
int digit() {
  int n = S[cur] - '0';
  cur++;
  return n;
}
int number() {
  int n = digit();
  while (cur < S.size() && isdigit(S[cur]))
    n = n*10 + digit();
  return n;
}
bool isdigit(char c) {
  if (c <= '9' and c >= '0') return true;
  else return false;
}
bool is_plu_min(char c) {
  if (c == '+' || c == '-') return true;
  else return false;
}
bool is_tim_div(char c) {
  if (c == '*' || c == '/') return true;
  else return false;
}
// exp    = term exp`
// exp`   = + term exp` | eps
// term   = factor term`
// term`  = * factor term` | eps
// factor = ( exp ) | num
int term() {
  int n = factor();
  return _term(n);
}
int _term(int m) {
  int n = m;
  switch (S[cur]) {
    case '*':
      cur++;
      n *= factor();
      return _term(n);
    case '/':
      cur++;
      n /= factor();
      return _term(n);
    default:
      return n;
  }
}
int factor() {
  if (S[cur] != '(') return number();
  else {
    cur++;
    int n = exp();
    if (S[cur] != ')') {printf("%s\n","Error about Paren");return 1000000000;}
    cur++;
    return n;
  }
}
int exp() {
  int n = term();
  return _exp(n);
}
int _exp(int m) {
  int n = m;
  switch (S[cur]) {
    case '+':
      cur++;
      n += term();
      return _exp(n);
    case '-':
      cur++;
      n -= term();
      return _exp(n);
    default:
      return n;
  }
}
int parse() {
  return exp();

Compiler output:
a.cc: In function 'int parse()':
a.cc:106:16: error: expected '}' at end of input
  106 |   return exp();
      |                ^
a.cc:105:13: note: to match this '{'
  105 | int parse() {
      |             ^
Language: C++

#include <string>
#include <vector>
#include <iostream>
using namespace std;
string S; int n, junjo[4] = { 0, 0, 1, 1 };
long long calc(int L,int R){
    int K=0;
    vector<int>junjo2[4];
    for(int i=0;i<4;i++){
        junjo2[junjo[i]].push_back(i);
    }
    for(int i=0;i<4;i++){
        if(junjo2[i].size()>=1){
            for(int j=R-1;j>=L;j--){
                if(S[j]=='('){K++;}
                if(S[j]==')'){K--;}
                for(int k=0;k<junjo2[i].size();k++){
                    if(junjo2[i][k]==0){
                        if(S[j]=='+' && K==0){
                            return calc(L,j)+calc(j+1,R);
                        }
                    }
                    if(junjo2[i][k]==1){
                        if(S[j]=='-' && K==0){
                            return calc(L,j)-calc(j+1,R);
                        }
                    }
                    if(junjo2[i][k]==2){
                        if(S[j]=='*' && K==0){
                            return calc(L,j)*calc(j+1,R);
                        }
                    }
                    if(junjo2[i][k]==3){
                        if(S[j]=='/' && K==0){
                            return calc(L,j)/calc(j+1,R);
                        }
                    }
                }
            }
        }
    }
    if(S[L]=='(' && S[R-1]==')'){return calc(L+1,R-1);}
    return stoi(S.substr(L,R-L));
}
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) cin >> s, printf("%d\n", calc(0, s.size() - 1));
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:43: error: 's' was not declared in this scope
   47 |         for(int i = 0; i < n; i++) cin >> s, printf("%d\n", calc(0, s.size() - 1));
      |                                           ^
Language: C++

#include <iostream>
#include <cmath>
#include <stack>
#include <algorithm>
#include <sstream>
using namespace std;
int hoge(string a)
{
	if(a=="(")return -1;
	if(a=="*"||a=="/")return 1;
	return 0;
}

long long calc(long long a,long long b,string str)
{
	if(str=="+")return a+b;
	if(str=="-")return a-b;
	if(str=="/")return a/b;
	if(str=="*")return a*b;
	
}

int main()
{
	int n;cin>>n;
	while(n--)
	{
		string str;cin>>str;
		stringstream ss;
		for(int i=0;i<str.size()-1;i++)
		{
			if(str[i]=='+'||str[i]=='-'||str[i]=='/'||str[i]=='*'||str[i]=='('||str[i]==')')ss<<" "<<str[i]<<" ";
			else ss<<str[i];
		}
		
		vector<string> v;
		stack<string> st;
		while(getline(ss,str,' '))
		{
			if(str=="")continue;
			if(str=="+"||str=="-"||str=="/"||str=="*")
			{
				while(!st.empty()&&hoge(st.top())>hoge(str))
				{
					v.push_back(st.top());
					st.pop();
				}
				st.push(str);
			}
			else if(str==")")
			{
				while(st.top()!="(")
				{
					v.push_back(st.top());
					st.pop();
				}
				st.pop();
			}
			else if(str=="(")st.push(str);
			else v.push_back(str);
		}
		while(!st.empty())
		{
			
			v.push_back(st.top());
			st.pop();
		}
		stack<long long> k;
		for(int i=0;i<v.size();i++)
		{
			
			if(v[i]=="+"||v[i]=="-"||v[i]=="/"||v[i]=="*")
			{
				long long A,B;
				B=k.top();k.pop();
				A=k.top();k.pop();
				k.push(calc(A,B,v[i]));
			}
			else
			{
				k.push(atol(v[i].c_str()));
			}
		}
				cout<<k.top()<<endl;
	}
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:17: error: 'vector' was not declared in this scope
   36 |                 vector<string> v;
      |                 ^~~~~~
a.cc:6:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    5 | #include <sstream>
  +++ |+#include <vector>
    6 | using namespace std;
a.cc:36:30: error: expected primary-expression before '>' token
   36 |                 vector<string> v;
      |                              ^
a.cc:36:32: error: 'v' was not declared in this scope
   36 |                 vector<string> v;
      |                                ^
a.cc: In function 'long long int calc(long long int, long long int, std::string)':
a.cc:21:1: warning: control reaches end of non-void function [-Wreturn-type]
   21 | }
      | ^
Language: C++

#include <iostream>
#include <cmath>
#include <stack>
#include <algorithm>
#include <sstream>
using namespace std;
int hoge(string a)
{
	if(a=="(")return -1;
	if(a=="*"||a=="/")return 1;
	return 0;
}

long long calc(long long a,long long b,string str)
{
	if(str=="+")return a+b;
	if(str=="-")return a-b;
	if(str=="/")return a/b;
	if(str=="*")return a*b;
	
}

int main()
{
	int n;cin>>n;
	while(n--)
	{
		string str;cin>>str;
		stringstream ss;
		for(int i=0;i<str.size()-1;i++)
		{
			if(str[i]=='+'||str[i]=='-'||str[i]=='/'||str[i]=='*')ss<<" "<<str[i]<<" ";
			else if(str[i]=='(')ss<<"( ";
			else if(str[i]==')')ss<<" )";
			else ss<<str[i];
		}
		
		vector<string> v;
		stack<string> st;
		while(getline(ss,str,' '))
		{
			//if(str=="")continue;
			if(str=="+"||str=="-"||str=="/"||str=="*")
			{
				while(!st.empty()&&hoge(st.top())>hoge(str))
				{
					v.push_back(st.top());
					st.pop();
				}
				st.push(str);
			}
			else if(str==")")
			{
				while(st.top()!="(")
				{
					v.push_back(st.top());
					st.pop();
				}
				st.pop();
			}
			else if(str=="(")st.push(str);
			else v.push_back(str);
		}
		while(!st.empty())
		{
			v.push_back(st.top());
			st.pop();
		}
		stack<long long> k;
		for(int i=0;i<v.size();i++)
		{
			if(v[i]=="+"||v[i]=="-"||v[i]=="/"||v[i]=="*")
			{
				long long A,B;
				B=k.top();k.pop();
				A=k.top();k.pop();
				k.push(calc(A,B,v[i]));
			}
			else
			{
				k.push(atol(v[i].c_str()));
			}
		}
		cout<<k.top()<<endl;
	}
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:17: error: 'vector' was not declared in this scope
   38 |                 vector<string> v;
      |                 ^~~~~~
a.cc:6:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    5 | #include <sstream>
  +++ |+#include <vector>
    6 | using namespace std;
a.cc:38:30: error: expected primary-expression before '>' token
   38 |                 vector<string> v;
      |                              ^
a.cc:38:32: error: 'v' was not declared in this scope
   38 |                 vector<string> v;
      |                                ^
a.cc: In function 'long long int calc(long long int, long long int, std::string)':
a.cc:21:1: warning: control reaches end of non-void function [-Wreturn-type]
   21 | }
      | ^
Language: C++

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

int cur;
string s;

int digit() {
	return ( s[cur++] - '0' );
}

int number() {
	int n = digit();
	while ( isdigit( s[cur] ) )
		n = n * 10 + digit();
	return n;
}

int factor() {
	int n;
	if ( s[cur] == '(' ) {
		cur++;
		n = expression();
		cur++;
	} else
		n = number();
	return n;
}

int term() {
	int n = factor();
	while ( s[cur] == '*' || s[cur] == '/' ) {
		cur++;
		if ( s[cur - 1] == '*' )
			n *= factor();
		else
			n /= factor();
	}
	return n;
}

int expression() {
	int n = term();
	while ( s[cur] == '+' || s[cur] == '-' ) {
		cur++;
		if ( s[cur - 1] == '+' )
			n += term();
		else
			n -= term();
	}
	return n;
}

int main() {
	int n;
	cin >> n;
	for ( int i = 0; i < n; i++ ) {
		cur = 0;
		cin >> s;
		int m = expression();
		cout << m << endl;
	}
}

Compiler output:
a.cc: In function 'int factor()':
a.cc:24:21: error: 'expression' was not declared in this scope
   24 |                 n = expression();
      |                     ^~~~~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <cctype>
using namespace std;

typedef string::const_iterator State;
int n;
string str;

int factor(State &begin);
int number(State &begin);
int term(State &begin);
int expressin(State &begin);

int factor(State &begin)
{
	int ret;
	if (*begin == '(')
	{
		begin++;
		ret = expressin(begin);
		begin++;
	}
	else
	{
		ret = number(begin);
	}
	return ret;
}

int number(State &begin)
{
	int ret = 0;
	while (isdigit(*begin))
	{
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	return ret;
}

int term(State &begin)
{
	int ret = factor(begin);
	while (true)
	{
		if (*begin == '*')
		{
			begin++;
			ret *= factor(begin);
		}
		else if (*begin == '/')
		{
			begin++;
			ret /= factor(begin);
		}
		else
		{
			break;
		}
	}

	return ret;
}

int expressin(State &begin)
{
	int ret = term(begin);
	while (true)
	{
		if (*begin == '+')
		{
			begin++;
			ret += term(begin);
		}
		else if (*begin == '-')
		{
			begin++;
			ret -= term(begin);
		}
		else
		{
			break;
		}
	}

	return ret;
}


int main()
{
	cin >> n;
	while (n--)
	{
		cin >> str;
		cout << expressin(str.begin()) << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:100:44: error: cannot bind non-const lvalue reference of type 'State&' {aka 'std::__cxx11::basic_string<char>::const_iterator&'} to an rvalue of type 'State' {aka 'std::__cxx11::basic_string<char>::const_iterator'}
  100 |                 cout << expressin(str.begin()) << endl;
      |                                   ~~~~~~~~~^~
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:1:
/usr/include/c++/14/bits/stl_iterator.h:1074:9: note:   after user-defined conversion: '__gnu_cxx::__normal_iterator<_Iterator, _Container>::__normal_iterator(const __gnu_cxx::__normal_iterator<_Iter, _Container>&) [with _Iter = char*; <template-parameter-2-2> = void; _Iterator = const char*; _Container = std::__cxx11::basic_string<char>]'
 1074 |         __normal_iterator(const __normal_iterator<_Iter, _Container>& __i)
      |         ^~~~~~~~~~~~~~~~~
a.cc:69:22: note:   initializing argument 1 of 'int expressin(State&)'
   69 | int expressin(State &begin)
      |               ~~~~~~~^~~~~
Language: C++

#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <cctype>
using namespace std;

typedef string::iterator State;
int n;
string str;

int factor(State &begin);
int number(State &begin);
int term(State &begin);
int expressin(State &begin);

int factor(State &begin)
{
	int ret;
	if (*begin == '(')
	{
		begin++;
		ret = expressin(begin);
		begin++;
	}
	else
	{
		ret = number(begin);
	}
	return ret;
}

int number(State &begin)
{
	int ret = 0;
	while (isdigit(*begin))
	{
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	return ret;
}

int term(State &begin)
{
	int ret = factor(begin);
	while (true)
	{
		if (*begin == '*')
		{
			begin++;
			ret *= factor(begin);
		}
		else if (*begin == '/')
		{
			begin++;
			ret /= factor(begin);
		}
		else
		{
			break;
		}
	}

	return ret;
}

int expressin(State &begin)
{
	int ret = term(begin);
	while (true)
	{
		if (*begin == '+')
		{
			begin++;
			ret += term(begin);
		}
		else if (*begin == '-')
		{
			begin++;
			ret -= term(begin);
		}
		else
		{
			break;
		}
	}

	return ret;
}


int main()
{
	cin >> n;
	while (n--)
	{
		cin >> str;
		cout << expressin(str.begin()) << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:100:44: error: cannot bind non-const lvalue reference of type 'State&' {aka 'std::__cxx11::basic_string<char>::iterator&'} to an rvalue of type 'std::__cxx11::basic_string<char>::iterator'
  100 |                 cout << expressin(str.begin()) << endl;
      |                                   ~~~~~~~~~^~
a.cc:69:22: note:   initializing argument 1 of 'int expressin(State&)'
   69 | int expressin(State &begin)
      |               ~~~~~~~^~~~~
Language: C++

n=int(input())
for i in range(n):
	a=input()
	b=""
	for i in a:
		b+=i
		if i=='/':b+='/'
	print(int(eval(b[:len(b)-1])))

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n=int(input())
      | ^
Language: C++

import re
class c:
	def __str__(self):
		return str(self.x)
	def __init__(self,value):
		self.x=value
	def __add__(self,value):
		return c(self.x+value.x)
	def __sub__(self,value):
		return c(self.x-value.x)
	def __mul__(self,value):
		return c(self.x*value.x)
	def __truediv__(self,value):
		return c(int(self.x/value.x))
n=int(input())
for i in range(n):
	s=input()[:-1]
	s=re.sub(r'(\d+)',r'c(\1)',s)
	print(eval(s))

Compiler output:
a.cc:18:19: warning: unknown escape sequence: '\d'
   18 |         s=re.sub(r'(\d+)',r'c(\1)',s)
      |                   ^~~~~~~
a.cc:18:19: warning: multi-character character constant [-Wmultichar]
a.cc:18:28: warning: multi-character character constant [-Wmultichar]
   18 |         s=re.sub(r'(\d+)',r'c(\1)',s)
      |                            ^~~~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import re
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

# -*- coding: utf-8 -*-

num = int(raw_input())
for i in range(num):
	input_line = raw_input()
	eval_line = input_line[0:-1]
	result = eval(eval_line)
	print result

Compiler output:
a.cc:1:3: error: invalid preprocessing directive #-
    1 | # -*- coding: utf-8 -*-
      |   ^
a.cc:3:1: error: 'num' does not name a type; did you mean 'enum'?
    3 | num = int(raw_input())
      | ^~~
      | enum
Language: C++

#include <iostream>

int main()
{
cout << endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:1: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
    5 | cout << endl;
      | ^~~~
      | std::cout
In file included from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:5:9: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
    5 | cout << endl;
      |         ^~~~
      |         std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include <iostream>

int main()
{
std::cout << endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:14: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
    5 | std::cout << endl;
      |              ^~~~
      |              std::endl
In file included from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++


#include <iostream>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <cctype>
using namespace std;

typedef string::const_iterator State;
int expression(State &begin);

int number(State &begin) {
	int ret = 0;
	for (; isdigit(*begin);) {
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	return ret;
}
int factor(State &begin) {
	int ret;
	if (*begin == '(') {
		begin++;
		ret = expression(begin);
		begin++;
	}
	else {
		return number(begin);
	}
	return ret;
}
int term(State &begin) {
	int ret = factor(begin);
	for (;;) {
		if (*begin == '*') {
			ret *= term(++begin);
		}
		else if (*begin == '/') {
			ret /= term(++begin);
		}
		else break;
	}
	return ret;
}


int expression(State &begin) {
	int ret = term(begin);
	for (;;) {
		if (*begin == '+') {
			ret += term(++begin);
		}
		else if (*begin == '-') {
			ret -= term(++begin);
		}
		else break;
	}
	return ret;
}

int main() {
	int N;
	cin >> N;
	cin.ignore();
	for (int i = 0; i < N; i++) {
		string str;
		getline(cin, str);
		cout << expression(str.begin()) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:45: error: cannot bind non-const lvalue reference of type 'State&' {aka 'std::__cxx11::basic_string<char>::const_iterator&'} to an rvalue of type 'State' {aka 'std::__cxx11::basic_string<char>::const_iterator'}
   70 |                 cout << expression(str.begin()) << endl;
      |                                    ~~~~~~~~~^~
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:2:
/usr/include/c++/14/bits/stl_iterator.h:1074:9: note:   after user-defined conversion: '__gnu_cxx::__normal_iterator<_Iterator, _Container>::__normal_iterator(const __gnu_cxx::__normal_iterator<_Iter, _Container>&) [with _Iter = char*; <template-parameter-2-2> = void; _Iterator = const char*; _Container = std::__cxx11::basic_string<char>]'
 1074 |         __normal_iterator(const __normal_iterator<_Iter, _Container>& __i)
      |         ^~~~~~~~~~~~~~~~~
a.cc:49:23: note:   initializing argument 1 of 'int expression(State&)'
   49 | int expression(State &begin) {
      |                ~~~~~~~^~~~~
Language: C++


#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <cctype>
using namespace std;

typedef string::const_iterator State;
int expression(State &begin);

int number(State &begin) {
	int ret = 0;
	for (; isdigit(*begin);) {
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	return ret;
}
int factor(State &begin) {
	int ret;
	if (*begin == '(') {
		begin++;
		ret = expression(begin);
		begin++;
	}
	else {
		return number(begin);
	}
	return ret;
}
int term(State &begin) {
	int ret = factor(begin);
	for (;;) {
		if (*begin == '*') {
			ret *= term(++begin);
		}
		else if (*begin == '/') {
			ret /= term(++begin);
		}
		else break;
	}
	return ret;
}


int expression(State &begin) {
	int ret = term(begin);
	for (;;) {
		if (*begin == '+') {
			ret += term(++begin);
		}
		else if (*begin == '-') {
			ret -= term(++begin);
		}
		else break;
	}
	return ret;
}

int main() {
	int N;
	cin >> N;
	cin.ignore();
	for (int i = 0; i < N; i++) {
		string str;
		getline(cin, str);
		cout << expression(str.begin()) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:69:45: error: cannot bind non-const lvalue reference of type 'State&' {aka 'std::__cxx11::basic_string<char>::const_iterator&'} to an rvalue of type 'State' {aka 'std::__cxx11::basic_string<char>::const_iterator'}
   69 |                 cout << expression(str.begin()) << endl;
      |                                    ~~~~~~~~~^~
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:2:
/usr/include/c++/14/bits/stl_iterator.h:1074:9: note:   after user-defined conversion: '__gnu_cxx::__normal_iterator<_Iterator, _Container>::__normal_iterator(const __gnu_cxx::__normal_iterator<_Iter, _Container>&) [with _Iter = char*; <template-parameter-2-2> = void; _Iterator = const char*; _Container = std::__cxx11::basic_string<char>]'
 1074 |         __normal_iterator(const __normal_iterator<_Iter, _Container>& __i)
      |         ^~~~~~~~~~~~~~~~~
a.cc:48:23: note:   initializing argument 1 of 'int expression(State&)'
   48 | int expression(State &begin) {
      |                ~~~~~~~^~~~~
Language: C++


#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <cctype>
using namespace std;

typedef string::const_iterator State;
int expression(State &begin);

int number(State &begin) {
	int ret = 0;
	for (; isdigit(*begin);) {
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	return ret;
}
int factor(State &begin) {
	int ret;
	if (*begin == '(') {
		begin++;
		ret = expression(begin);
		begin++;
	}
	else {
		return number(begin);
	}
	return ret;
}
int term(State &begin) {
	int ret = factor(begin);
	for (;;) {
		if (*begin == '*') {
			ret *= term(++begin);
		}
		else if (*begin == '/') {
			ret /= term(++begin);
		}
		else break;
	}
	return ret;
}


int expression(State &begin) {
	int ret = term(begin);
	for (;;) {
		if (*begin == '+') {
			ret += term(++begin);
		}
		else if (*begin == '-') {
			ret -= term(++begin);
		}
		else break;
	}
	return ret;
}

int main() {
	int N;
	cin >> N;
	cin.ignore();
	for (int i = 0; i < N; i++) {
		string str;
		getline(cin, str);
State s = str.begin();
		cout << expression(str.begin()) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:45: error: cannot bind non-const lvalue reference of type 'State&' {aka 'std::__cxx11::basic_string<char>::const_iterator&'} to an rvalue of type 'State' {aka 'std::__cxx11::basic_string<char>::const_iterator'}
   70 |                 cout << expression(str.begin()) << endl;
      |                                    ~~~~~~~~~^~
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:2:
/usr/include/c++/14/bits/stl_iterator.h:1074:9: note:   after user-defined conversion: '__gnu_cxx::__normal_iterator<_Iterator, _Container>::__normal_iterator(const __gnu_cxx::__normal_iterator<_Iter, _Container>&) [with _Iter = char*; <template-parameter-2-2> = void; _Iterator = const char*; _Container = std::__cxx11::basic_string<char>]'
 1074 |         __normal_iterator(const __normal_iterator<_Iter, _Container>& __i)
      |         ^~~~~~~~~~~~~~~~~
a.cc:48:23: note:   initializing argument 1 of 'int expression(State&)'
   48 | int expression(State &begin) {
      |                ~~~~~~~^~~~~
Language: C++

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <cctype>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

typedef string::const_iterator State;
class ParseError {};

int number(State &begin);
int factor(State &begin);
int term(State &begin);
int factor(State &begin);

// ??°?????????????????????
int number(State &begin) {
    int ret = 0;
    while(isdigit(*begin)) {
        ret *= 10;
        ret += (*begin - '0');
        begin++;
    }
    return ret;
}

// ??¬??§?????°????????????
int factor(State &begin) {
    if(*begin == '(') {
        begin++; // '(' ????£???°???
        int ret = expression(begin);
        begin++; // ')' ????£???°???
        return ret;
    }
    else return number(begin);
}

// ??????????????????????????????
int term(State &begin) {
    // ????????????????????¨????????£????????°??????????????§???????????????
    // begin ?????????????????°?????§???????????????
    int ret = factor(begin);

    while(1) {
        if(*begin == '*') {
            begin++;
            ret *= factor(begin);
        }
        else if(*begin == '/') {
            begin++;
            ret /= factor(begin);
        }
        else break;
    }

    return ret;
}

// ??????????????????????????????
int expression(State &begin) {
    int ret = term(begin);
    while(1) {
        if(*begin == '+') {
            begin++;
            ret += term(begin);
        }
        else if(*begin == '-') {
            begin++;
            ret -= term(begin);
        }
        else break;
    }
    return ret;
}

signed main() {
    int N; cin >> N;
    rep(i,0,N) {
        string s; cin >> s;
        State begin = s.begin();
        int ans = expression(begin);
        cout << ans << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'long long int factor(State&)':
a.cc:67:19: error: 'expression' was not declared in this scope
   67 |         int ret = expression(begin);
      |                   ^~~~~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <stack>
#include <map>
#include <cstdlib>
#include <cctype>
#include <cstdio>
#include <cstring>

using namespace std;

int str2arr(char s[], string A[]) {
    bool flag = true;
    string t;
    int l = strlen(s);
    int i, n = 0;
    for (i = 0; i < l; i++) {
        if (isdigit(s[i]) && flag) {
            t = "";
            int j = 0;
            while (isdigit(s[i + j])) {
                t += s[i + j];
                if (i + j == l - 1)
                    break;
                j++;
            }
            A[n++] = t;
            flag = false;
        }
        else if (!isdigit(s[i])) {
            A[n++] = s[i];
            flag = true;
        }
    }
    return n;
}

int Generate_RPN(int n, string A[], string B[]) {
    map<string, int> table;
    table["*"] = 1;
    table["/"] = 1;
    table["+"] = 0;
    table["-"] = 0;
    table["("] = -1;
    table[")"] = -1;
    stack<string> S;
    int j = 0;

    for (int i = 0; i < n; i++) {
        if (isdigit(A[i][0])) {
            B[j++] = A[i];
        }

        else if (A[i] == "(")
            S.push(A[i]);

        else if (A[i] == ")") {
            while (S.top() != "(") {
                B[j++] = S.top();
                S.pop();
            }
            S.pop();
        }
        else {
            while ((!S.empty()) && (table[S.top()] >= table[A[i]])) {
                B[j++] = S.top();
                S.pop();
            }
            S.push(A[i]);
        }
    }
    while (!S.empty()) {
        B[j++] = S.top();
        S.pop();
    }
    return j;
}

void calculate(int n, string s[]) {
    stack<double> St;
    double a, b;

    for (int i = 0; i < n; i++) {
        if (s[i] == "+") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a+b);
        }
        else if (s[i] == "-") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a+b);
        }
        else if (s[i] == "*") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a*b);
        }
        else if (s[i] == "/") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a/b);
        }
        else {
            St.push(atoi(s[i].c_str()));
        }
    }
    cout << int(St.top()) << endl;
}

int main()
{
    int n, l, t;
    string A[101], B[101];
    char s[101];

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        s[0] = '\0';
        scanf("%s", s);
        s[strlen(s)-1] = '\0'; //????°????=?????????

        l = str2arr(s, A);
        t = Generate_RPN(l, A, B);

        calculate(t, B);
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:119:10: error: 'i' was not declared in this scope
  119 |     for (i = 0; i < n; i++) {
      |          ^
Language: C++

#include <iostream>
#include <string>
#include <stack>
#include <map>
#include <cstdlib>
#include <cctype>
#include <cstdio>
#include <cstring>

using namespace std;

int str2arr(char s[], string A[]) {
    bool flag = true;
    string t;
    int l = strlen(s);
    int n = 0;
    for (i = 0; i < l; i++) {
        if (isdigit(s[i]) && flag) {
            t = "";
            int j = 0;
            while (isdigit(s[i+j])) {
                t += s[i+j];
                if (i+j == l-1)
                    break;
                j++;
            }
            A[n++] = t;
            flag = false;
        }
        else if (!isdigit(s[i])) {
            A[n++] = s[i];
            flag = true;
        }
    }
    return n;
}

int Generate_RPN(int n, string A[], string B[]) {
    map<string, int> table;
    table["*"] = 1;
    table["/"] = 1;
    table["+"] = 0;
    table["-"] = 0;
    table["("] = -1;
    table[")"] = -1;
    stack<string> S;
    int j = 0;

    for (int i = 0; i < n; i++) {
        if (isdigit(A[i][0])) {
            B[j++] = A[i];
        }

        else if (A[i] == "(")
            S.push(A[i]);

        else if (A[i] == ")") {
            while (S.top() != "(") {
                B[j++] = S.top();
                S.pop();
            }
            S.pop();
        }
        else {
            while ((!S.empty()) && (table[S.top()] >= table[A[i]])) {
                B[j++] = S.top();
                S.pop();
            }
            S.push(A[i]);
        }
    }
    while (!S.empty()) {
        B[j++] = S.top();
        S.pop();
    }
    return j;
}

void calculate(int n, string s[]) {
    stack<double> St;
    double a, b;

    for (int i = 0; i < n; i++) {
        if (s[i] == "+") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a+b);
        }
        else if (s[i] == "-") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a-b);
        }
        else if (s[i] == "*") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a*b);
        }
        else if (s[i] == "/") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a/b);
        }
        else {
            St.push(atoi(s[i].c_str()));
        }
    }
    cout << int(St.top()) << endl;
}

int main()
{
    int n, l, t;
    string A[101], B[101];
    char s[101];

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        s[0] = '\0';
        scanf("%s", s);
        s[strlen(s)-1] = '\0';

        l = str2arr(s, A);
        t = Generate_RPN(l, A, B);

        calculate(t, B);
    }

    return 0;
}

Compiler output:
a.cc: In function 'int str2arr(char*, std::string*)':
a.cc:17:10: error: 'i' was not declared in this scope
   17 |     for (i = 0; i < l; i++) {
      |          ^
Language: C++

#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e17;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14


int expr(const char **);
int term(const char **);
int factor(const char **);
int number(const char **);

int expr(const char **p) {
  int val = term(p);
  while (1) {
    if (**p == '+') {
      (*p)++;
      val += term(p);
    } else if (**p == '-') {
      (*p)++;
      val -= term(p);
    } else {
      break;
    }
  }
  return val;
}

int term(const char **p) {
  int val = factor(p);
  while (1) {
    if (**p == '*') {
      (*p)++;
      val *= factor(p);
    } else if (**p == '/') {
      (*p)++;
      val /= factor(p);
    } else {
      break;
    }
  }
  return val;
}

int factor(const char **p) {
  if (**p == '(') {
    (*p)++;
    int val = expr(p);
    (*p)++;
    return val;
  }
  return number(p);
}

int number(const char **p) {
  int val = 0;
  while ('0' <= **p && **p <= '9') {
    val = val * 10 + **p - '0';
    (*p)++;
  }
  return val;
}

int main() {
  int n;
  scanf("%d", &n);
  char s[101];
  while (n--) {
    scanf("%s", s);
    const char *p = s;
    printf("%d\n", expr(&p));
  }
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <bits/stdc++.h>
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e17;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14


int expr(const char **);
int term(const char **);
int factor(const char **);
int number(const char **);

int expr(const char **p) {
  int val = term(p);
  while (1) {
    if (**p == '+') {
      (*p)++;
      val += term(p);
    } else if (**p == '-') {
      (*p)++;
      val -= term(p);
    } else {
      break;
    }
  }
  return val;
}

int term(const char **p) {
  int val = factor(p);
  while (1) {
    if (**p == '*') {
      (*p)++;
      val *= factor(p);
    } else if (**p == '/') {
      (*p)++;
      val /= factor(p);
    } else {
      break;
    }
  }
  return val;
}

int factor(const char **p) {
  if (**p == '(') {
    (*p)++;
    int val = expr(p);
    (*p)++;
    return val;
  }
  return number(p);
}

int number(const char **p) {
  int val = 0;
  while ('0' <= **p && **p <= '9') {
    val = val * 10 + **p - '0';
    (*p)++;
  }
  return val;
}

int main() {
  int n;
  scanf("%d", &n);
  char s[101];
  while (n--) {
    scanf("%s", s);
    const char *p = s;
    printf("%d\n", expr(&p));
  }
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef pair<int,const char*> parsed;

parsed expr(const char*);
parsed term(const char*);
parsed fact(const char*);

parsed expr(const char* s)
{
	//cout<<"expr(\""<<s<<"\")"<<endl;
	parsed now=term(s);
	while(*now.second!='=' && *now.second!=')'){
		char op=*now.second;
		parsed next=term(now.second+1);
		if(op=='+')
			now=parsed(now.first+next.first,next.second);
		else
			now=parsed(now.first-next.first,next.second);
	}
	//cout<<"expr(\""<<s<<"\")="<<now.first<<endl;
	return now;
}

parsed term(const char* s)
{
	//cout<<"term(\""<<s<<"\")"<<endl;
	parsed now=fact(s);
	while(*now.second!='=' && *now.second!=')' && *now.second!='+' && *now.second!='-'){
		char op=*now.second;
		parsed next=fact(now.second+1);
		if(op=='*')
			now=parsed(now.first*next.first,next.second);
		else
			now=parsed(now.first/next.first,next.second);
	}
	//cout<<"term(\""<<s<<"\")="<<now.first<<endl;
	return now;
}

parsed fact(const char* s)
{
	//cout<<"fact(\""<<s<<"\")"<<endl;
	if(s[0]=='('){
		parsed res=expr(s+1);
		res.second++;
		return res;
	}
	else{
		const char* p=s;
		if(*p=='-')
			p++;
		while(isdigit(*p))
			p++;
		return parsed(atoi(s),p);
	}
}

int main()
{
	//parsed p=expr("((3+4)/(1+2))=");
	//cout<<p.first<<","<<p.second<<endl;
	char s[101];
	gets(s);
	while(gets(s))
		cout<<expr(s).first<<endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:107:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
  107 |         gets(s);
      |         ^~~~
      |         getw
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<cstdio>

using namespace std;

char siki[200];
int cur;


int digit(){
  int n=siki[cur]-'0';
  ++cur;
  return n;
}

int number(){
  int n=digit();
  while(cur<strlen(siki) && isdigit(siki[cur]))
    n=n*10+digit();

  return n;
}

int factor();

int term(){
  int a=factor();
  while(cur<strlen(siki) && (siki[cur]=='*' || siki[cur]=='/')){
    char op=siki[cur];
    ++cur;
    int b=factor();
    if(op=='*')a*=b;else a/=b;
  }
  return a;
}

int expression(){
  int a=term();
  while(cur<strlen(siki) && (siki[cur]=='+' || siki[cur]=='-')){
    char op=siki[cur];
    cur++;
    int b=term();
    if(op=='+')a+=b;else a-=b;
  }
  return a;
}

int factor(){
  if(siki[cur]!='(')return number();
  cur++;
  int n=expression();
  cur++;
  return n;
}

int main(){
  int n;
  cin>>n;

  for(int i=0;i<n;i++){
    cin>>siki;
    cur=0;
    cout<<expression()<<endl;
  }
}

Compiler output:
a.cc: In function 'int number()':
a.cc:20:13: error: 'strlen' was not declared in this scope
   20 |   while(cur<strlen(siki) && isdigit(siki[cur]))
      |             ^~~~~~
a.cc:5:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include<cstdio>
  +++ |+#include <cstring>
    5 | 
a.cc: In function 'int term()':
a.cc:30:13: error: 'strlen' was not declared in this scope
   30 |   while(cur<strlen(siki) && (siki[cur]=='*' || siki[cur]=='/')){
      |             ^~~~~~
a.cc:30:13: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc: In function 'int expression()':
a.cc:41:13: error: 'strlen' was not declared in this scope
   41 |   while(cur<strlen(siki) && (siki[cur]=='+' || siki[cur]=='-')){
      |             ^~~~~~
a.cc:41:13: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include <stdio.h>

char formula[101];
int p;

int additive() {
  int result = multitive();
  while (formula[p] == '+' || formula[p] == '-')
    if (formula[p++] == '+')
      result += multitive();
    else
      result -= multitive();
  return result;
}

int multitive() {
  int result = term();
  while (formula[p] == '*' || formula[p] == '/')
    if (formula[p++] == '*')
      result *= term();
    else
      result /= term();
  return result;
}

int term() {
  int result = 0;
  if (formula[p] == '(') {
    p++;
    result = additive();
    p++;
  } else while ('0' <= formula[p] && formula[p] <= '9')
    result = result * 10 + formula[p++] - '0';
  return result;
}

int main() {
  int i, n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", formula);
    p = 0;
    printf("%d\n", additive());
  }
  return 0;
}

Compiler output:
a.cc: In function 'int additive()':
a.cc:7:16: error: 'multitive' was not declared in this scope
    7 |   int result = multitive();
      |                ^~~~~~~~~
a.cc: In function 'int multitive()':
a.cc:17:16: error: 'term' was not declared in this scope
   17 |   int result = term();
      |                ^~~~
Language: C++

#include<iostream>
#include<cstdlib>
using namespace std;
typedef pair<int,const char*>parsed;
parsed expr(const char *p);
parsed term(const char *p);
parsed fact(const char *p);
parsed expr(const char *p){
  parsed r=term(p);
 while(*r.second=='+'||*r.second=='-'){
    char op =*r.second;
    int tmp=r.first;
    r=term(r.second+1);
    if(op=='+')r.first=tmp+r.first;
    else r.first=tmp-r.first;
  }
  return r;
}
parsed term(const char *p){
  parsed r=fact(p);
  while(*r.second=='*'||*r.second=='/'){
    char op=*r.second;
    int tmp=r.first;
    r=fact(r.second+1);
    if(op=='*')r.first=tmp*r.first;
    else r.first=tmp/r.first;
  }
  return r;
}
parsed fact(const char *p){
  if(isdigit(*p)){
    int t=*(p++)-'0';
    while(isdigit(*p))t=t*10+*(p++)-'0';
    return parsed(t,p);
  }
  else if(*p=='('){
    parsed r=expr(p+1);
    if(*r.second!=')')exit(0);
    return parsed(r.first,r.second+1);
  }
  else exit(0);
}
main(n){
  string str;
  cin>>n;
  while(n--){
	  cin>>str;
    cout<<expr(str.c_str()).first<<endl;
  }
  return 0;
}

Compiler output:
a.cc:43:5: error: expected constructor, destructor, or type conversion before '(' token
   43 | main(n){
      |     ^
Language: C++

#include <iostream>
using namespace std;
char str[120];

int calc2(char *eq){
	int c=0,num[100]={0}, sign[100]={0};
	char *p = eq;
	while(*p){
		if('0'<=*p && *p<='9') num[c]=num[c]*10+*p-'0';
		else{
			if(*p=='+') sign[c]=1;
			else if(*p=='-') sign[c]=2;
			else if(*p=='*') sign[c]=3;
			else if(*p=='/') sign[c]=4;
			else if(*p=='=') break;
			else printf("err %c\n", *p);
			c++;
		}
		p++;
	}
	c++;
	for(int i=0;i<c;i++){
		if(sign[i]==3 || sign[i]==4){
			if(sign[i]==3)	num[i+1] = num[i] * num[i+1];
			if(sign[i]==4)	num[i+1] = num[i] / num[i+1];
			for(int j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	for(int i=0;i<c;i++){
		if(sign[i]==1 || sign[i]==2){
			if(sign[i]==1)	num[i+1] = num[i] + num[i+1];
			if(sign[i]==2)	num[i+1] = num[i] - num[i+1];
			for(int j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	printf("return %s=%d\n", eq, num[0]);
	return num[0];
}

int calc(char *eq){
	char *p, *p2, buf[120]={0}, cp[120]={0};
	int k,ret;
	strcpy(cp, eq);
	if(p=strchr(cp, '(')){
		for(k=0,p2=p+1;;p2++)
			if(*p2=='(')k++;
			else if(*p2==')'){
				if(k)k--;
				else break;
			}
		memcpy(buf, p+1, p2-p-1);
		buf[p2-p-1]='=';
		ret = calc(buf);
		*p=0;
		sprintf(buf, "%s%d%s", cp, ret, p2+1);
		strcpy(cp,buf);
	}
	return calc2(cp);
}

int main(){
	int i,j,n;
	char buf[120], p;
	for(cin >> n;n;n--){
		cin >> buf;
		cout << calc(buf) <<endl;
	}
}

Compiler output:
a.cc: In function 'int calc(char*)':
a.cc:53:9: error: 'strcpy' was not declared in this scope
   53 |         strcpy(cp, eq);
      |         ^~~~~~
a.cc:2:1: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
a.cc:54:14: error: 'strchr' was not declared in this scope
   54 |         if(p=strchr(cp, '(')){
      |              ^~~~~~
a.cc:54:14: note: 'strchr' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:61:17: error: 'memcpy' was not declared in this scope
   61 |                 memcpy(buf, p+1, p2-p-1);
      |                 ^~~~~~
a.cc:61:17: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'