Language: C++

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

const char symbollist[] = "+-*/()$;" ;//??????????????????
char SymbolJudge(char c, const char* str)//?????????????????¢??°
{
  for(size_t i = 0; str[i] != '\0'; ++i )
  {
    if( c == str[i])
    {
      return str[i] ;
    }
  }
  return 0 ;
}

int Judge(char *str)//()????????????????????????????????¢??°
{
  int pa_n = 0;
  for(size_t i = 0; str[i] != '\0'; ++i )
  {
    if(str[i] == '('){
      ++pa_n ;
    }
  }
  return pa_n ;
}

int Str(const char* str,const char* tar,const char* bul){//?????????????????¢??°
  char *temp ;
  size_t slen = strlen(str) ;
  size_t tlen = strlen(tar) ;
  size_t blen = strlen(bul) ;
  if((temp = strstr(str,tar)) == NULL){
    return 0 ;
  }
  memmove(temp + blen,temp + tlen,slen - (temp + tlen - str) + 1 ) ;
  memcpy(temp, bul , blen) ;
  return 1 ;
}
const int N = 200;
double EasyCalc(char *string){//()??????????¨????????????¢??°
  char formula[100] = {}, operators[N], temp[N], c ;
  size_t i, j = 0, nu_n = 0, op_n = 0 ;
  int tmp = 0  ;
  double num[N] ;
  strcpy(formula,string ) ;
  while(Str(formula," ","")) ;
  strcat(formula,";") ;
  for(i = 0,j = 0; formula[i] != '\0'; ++ i){
    if(SymbolJudge(formula[i], symbollist) == '-'){
      if(i == 0 || SymbolJudge(formula[i-1], symbollist) != 0){
        temp[j] = formula[i] ;
        ++j ;
        operators[op_n] = '+';
      }
      else{
        operators[op_n] = formula[i] ;
        ++op_n ;
        j = 0 ;
        num[nu_n] = atof(temp) ;
        ++ nu_n ;
        memset(temp,'\0', N);
      }
    }
    else if((c =SymbolJudge(formula[i], symbollist)) != 0){
      if(c != '('){
        operators[op_n] = formula[i] ;
        ++op_n ;
        j = 0 ;
        num[nu_n] = atof(temp) ;
        ++ nu_n ;
        memset(temp,'\0', N);
      }
    }
    else{
      temp[j] = formula[i] ;
      ++j ;
    }
  }
  tmp = 0 ;
  while(1){
    if((c=SymbolJudge(operators[tmp], symbollist) ) == ';'){
      break ;
    }
    switch(c){
      case '*':
        num[tmp] *= num[tmp + 1];
        num[tmp + 1] = 0 ;
        operators[tmp] = '\0' ;
        break ;
      case '/':
        num[tmp] /= num[tmp + 1];
        num[tmp + 1] = 0 ;
        operators[tmp] = '\0' ;
        break ;
      default:
        ++tmp ;
        break ;
    }
    for(j = 0; j < nu_n - 1; ++ j){
      if(num[j] == 0){
        num[j] = num[j + 1] ;
        num[j + 1] = 0 ;
      }
    }
    for(j = 0; j < op_n - 1; ++ j){
      if(operators[j] == '\0'){
        operators[j] = operators[j+1] ;
        operators[j + 1] = '\0' ;
      }
    }
  }
  tmp = 0 ;
  while(1){
    if((c=SymbolJudge(operators[0],symbollist)) == ';'){
      break ;
    }
    switch(c){
      case '+':
        num[tmp] += num[tmp + 1] ;
        num[tmp + 1] = 0 ;
        operators[tmp] = '\0' ;
        break ;
      case '-':
        num[tmp] -= num[tmp + 1] ;
        num[tmp + 1] = 0 ;
        operators[tmp] = '\0' ;
        break ;
      default:
        ++ tmp ;
        break ;
    }
    for(j = 0; j < nu_n - 1; ++ j){
      if(num[j] == 0){
        num[j] = num[j + 1] ;
        num[j + 1] = 0 ;
      }
    }
    for(j = 0; j < op_n - 1; ++ j){
      if(operators[j] == '\0'){
        operators[j] = operators[j+1] ;
        operators[j + 1] = '\0' ;
      }
    }
  }
  return num[0] ;
}
double Calculation(string str)//???????????£??????????¨??????????
{
  char* string = const_cast<char*>(str.c_str());
  bool flag = false ;
  char formula[N], formula1[N] = {}, operators[N], temp[N], c, buf[N] ;
  int flag_p = 0, pa_n = 0 ;
  size_t i, j = 0, nu_n = 0, op_n = 0, tmp = 0 ;
  double num[N] , ans;
  strcpy(formula,string ) ;
  while(1){//()??????????¨????????????¨???
    flag_p = Judge(formula) ;//()??????????????????????????????
    if(flag_p == 0 ){
      break ;
    }
    for(i = 0,j = 0,pa_n =0; formula[i] != '\0' ; ++ i){
      c = SymbolJudge(formula[i],symbollist) ;
      if(c == '('){
        ++pa_n ;
        if(flag_p == pa_n){
          formula[i] = '$' ;
          flag = true ;
        }
        j = 0;
        memset(formula1,'\0',N) ;
      }
      if(flag_p == pa_n){
        if(c == ')'){
          formula[i] = ' ' ;
          while(Str(formula1," ","")) ;
          while(Str(formula1,"\n","")) ;
          ans = EasyCalc(formula1) ;
          break ;
        }
        else{
          if(flag){
            flag = !flag ;
          }
          else{
            formula1[j] = formula[i] ;
            formula[i] = ' ' ;
            ++ j ;
          }
        }
      }
    }
    while(Str(formula," ","")) ;
    for(i = 0,j = 0; formula[i] != '\0' ; ++ i){
      c = SymbolJudge(formula[i],symbollist) ;
      if(c == '$'){
        sprintf(buf,"%lf",ans) ;
        Str(formula,"$", buf) ;
        break ;
      }
    }
  }

  strcat(formula,";") ;//????°?????????????????????§???????????¨???????????????????????????????¨?

  Str(formula,")","") ;
  for(i = 0,j = 0; formula[i] != '\0'; ++ i){
    if(SymbolJudge(formula[i], symbollist) == '-'){
      if(formula[i+1] != '\0' && SymbolJudge(formula[i+1], symbollist) == '-'){
        num[nu_n] = -1 ;
        ++nu_n ;
        operators[op_n] = '*' ;
        ++op_n ;
      }
      else if(i == 0 || SymbolJudge(formula[i-1], symbollist) != 0){//????????°??????????????????
        temp[j] = formula[i] ;
        ++j ;
        operators[op_n] = '+';
      }
      else{//???????????°?????¨???????????????????????????
        operators[op_n] = formula[i] ;//????????????????´?
        ++op_n ;
        j = 0 ;
        num[nu_n] = atof(temp) ;
        ++ nu_n ;
        memset(temp,'\0', N);
      }
    }
    else if((c =SymbolJudge(formula[i], symbollist)) != 0){//????????????????????°??§???????????§??????
      if(c != '('){
        operators[op_n] = formula[i] ;
        ++op_n ;
        j = 0 ;
        num[nu_n] = atof(temp) ;
        ++ nu_n ;
        memset(temp,'\0', N);
      }
    }
    else{//???????????§??????????????°??§??????
      temp[j] = formula[i] ;
      ++j ;
    }
  }
  while(1){//*/??????????????????
//         printf("%lf\n",num[nu_n-1]) ;
    if((c=SymbolJudge(operators[tmp], symbollist) ) == ';'){//???????????????????????????
      break ;
    }
    switch(c){//????´?????????????????????????????????£?????????????????????
      case '*':
        num[tmp] *= num[tmp + 1];
        num[tmp + 1] = INFINITY ;//????????¨?????\?????????????????¨??????
        operators[tmp] = '\0' ;//????????¨?????\???
        break ;
      case '/':
        num[tmp] /= num[tmp + 1];
        num[tmp + 1] = INFINITY ;
        operators[tmp] = '\0' ;
        break ;
      default://+-???????????§????¨?????????????
        ++tmp ;
        break ;
    }
    for(j = 0; j < nu_n - 1; ++ j){//????????¨?????\????????????????????????????????°????????????
      if(num[j] == INFINITY){
        num[j] = num[j + 1] ;
        num[j + 1] = INFINITY ;
      }
    }
    for(j = 0; j < op_n - 1; ++ j){//????§????
      if(operators[j] == '\0'){
        operators[j] = operators[j+1] ;
        operators[j + 1] = '\0' ;
      }
    }
  }
  tmp = 0 ;
  while(1){//+-?????????
    if((c=SymbolJudge(operators[0],symbollist)) == ';'){
      break ;
    }
    switch(c){//*/??¨?????????????????§??????
      case '+':
        num[tmp] += num[tmp + 1] ;
        num[tmp + 1] = INFINITY ;
        operators[tmp] = '\0' ;
        break ;
      case '-':
        num[tmp] -= num[tmp + 1] ;
        num[tmp + 1] = INFINITY ;
        operators[tmp] = '\0' ;
        break ;
      default:
        break ;
    }
    for(j = 0; j < nu_n - 1; ++ j){
      if(num[j] == INFINITY){
        num[j] = num[j + 1] ;
        num[j + 1] = INFINITY ;
      }
    }
    for(j = 0; j < op_n - 1; ++ j){
      if(operators[j] == '\0'){
        operators[j] = operators[j+1] ;
        operators[j + 1] = '\0' ;
      }
    }
  }
  return num[0] ;//??°????????????????????????????????????????´??????????
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string str;
  int n;
  cin >> n;
  getline(cin,str);
  rep(i,n){
    getline(cin,str);
    cout << Calculation(str) << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int Str(const char*, const char*, const char*)':
a.cc:87:20: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
   87 |   if((temp = strstr(str,tar)) == NULL){
      |              ~~~~~~^~~~~~~~~
      |                    |
      |                    const char*