Language: C++

#include<string>
#include<cctype>
typedef string::const_iterator State;
class Parse Error{};

int main(void){
  int N;
  cin >>N;
  cin.ignore()
  for(int i =0; i<N;i++){
    string s;
    getline(cin,s);

    State begibn =s.begin();
    int ans = expression(begin);
    cout << ans << endl;
  }
  return 0;
}

int number(state &begin){
  int ret =0;

  while(isdigit(*begin)){
    ret *= 10;
    ret +=~ *begin -'0';
    begin++;
  }

  return ret;
}

int term(State &begin){
  int ret =number(begin);

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

  return ret;
}

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

int expression(State &begin){
  int ret = term(begin);

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



Compiler output:
a.cc:3:9: error: 'string' does not name a type; did you mean 'stdin'?
    3 | typedef string::const_iterator State;
      |         ^~~~~~
      |         stdin
a.cc:4:13: error: variable 'Parse Error' has initializer but incomplete type
    4 | class Parse Error{};
      |             ^~~~~
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope
    8 |   cin >>N;
      |   ^~~
a.cc:10:17: error: 'i' was not declared in this scope
   10 |   for(int i =0; i<N;i++){
      |                 ^
a.cc: At global scope:
a.cc:21:12: error: 'state' was not declared in this scope; did you mean 'static'?
   21 | int number(state &begin){
      |            ^~~~~
      |            static
a.cc:21:19: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   21 | int number(state &begin){
      |                   ^~~~~
      |                   std::begin
In file included from /usr/include/c++/14/string:53,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:33:10: error: 'State' was not declared in this scope
   33 | int term(State &begin){
      |          ^~~~~
a.cc:33:17: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   33 | int term(State &begin){
      |                 ^~~~~
      |                 std::begin
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:51:12: error: 'State' was not declared in this scope
   51 | int factor(State &begin){
      |            ^~~~~
a.cc:51:19: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   51 | int factor(State &begin){
      |                   ^~~~~
      |                   std::begin
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:61:16: error: 'State' was not declared in this scope
   61 | int expression(State &begin){
      |                ^~~~~
a.cc:61:23: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   61 | int expression(State &begin){
      |                       ^~~~~
      |                       std::begin
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~