Go: package main

import (
	"bufio"
	"fmt"
	"go/token"
	"go/types"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n, _ := strconv.Atoi(stdin.Text())
	for i := 0; i < n; i++ {
		stdin.Scan()
		exp := strings.TrimRight(stdin.Text(), "=")
		res, _ := types.Eval(token.NewFileSet(), nil, token.NoPos, exp)
		fmt.Println(res.Value)
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

bool IsDigit(string::iterator &itr);
int expr(string::iterator &itr);
int factor(string::iterator &itr);
int number(string::iterator &itr);

int expr(string::iterator &itr) {
    int now = factor(itr);
    /*
    if(*itr == '+') {
        itr++;
        now += expr(itr);
        return now;
    }
    if(*itr == '-') {
        itr++;
        now -= expr(itr);
        return now;
    }
    return now;
    */
    while(true) {
        if(*itr == '+') {
            itr++;
            now += factor(itr);
            continue;
        }
        if(*itr == '-') {
            itr++;
            now -= factor(itr);
            continue;
        }
        //cerr << "expr:" << now << endl;
        return now;
    }
}

int factor(string::iterator &itr) {
    //cerr << "factor:" << *itr << endl;
    int now = number(itr);
    /*
    if(*itr == '*') {
        itr++;
        now *= factor(itr);
        return now;
    }
    if(*itr == '/') {
        itr++;
        now /= factor(itr);
        return now;
    }
    return now;
    */
    while(true) {
        if(*itr == '*') {
            itr++;
            now *= number(itr);
            continue;
        }
        if(*itr == '/') {
            itr++;
            now /= number(itr);
            continue;
        }
        //cerr << "factor:" << now << endl;
        return now;
    }
}

int number(string::iterator &itr) {
    //cerr << "number:" << *itr << endl;
    int now = 0;
    if(*itr == '(') {
        itr++;
        now = expr(itr);
        itr++;
        //cerr << "number:" << now << endl;
        return now;
    }
    while(IsDigit(itr)) {
        now *= 10;
        now += *itr - '0';
        itr++;
    }
    //cerr << "number:" << now << endl;
    return now;
}

bool IsDigit(string::iterator &itr) {
    return *itr <= '9' && *itr >= '0';
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    while(N--) {
        string S;
        cin >> S;
        auto itr = S.begin();
        cout << expr(itr) << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;

int pos;
string str;

int exp();

int factor() {
  if(str[pos] >= '0' && str[pos] <= '9') {
    string tmp = "";
    while(str[pos] >= '0' && str[pos] <= '9') {
      tmp += str[pos++];
    }
    return atoi(tmp.c_str());
  }

  if(str[pos] == '(') {
    pos++;
    return exp();
  } else if(str[pos] == ')') {
    pos++;
    return 0;
  }
}

int term() {
  int x = factor();
  while(str[pos] == '*' || str[pos] == '/') {
    if(str[pos] == '*') {
      pos++;
      x *= factor();
    } else if(str[pos] == '/') {
      pos++;
      x /= factor();
    }
  }
  return x;
}

int exp() {
  int x = term();
  while(str[pos] == '+' || str[pos] == '-') {
    if(str[pos] == '+') {
      pos++;
      x += term();
    } else if(str[pos] == '-') {
      pos++;
      x -= term();
    }
  }
  return x;
}

main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    pos = 0;
    cin >> str;
    str = str.substr(0, str.length()-1);
    cout << exp() << endl;
  }
}

C++: #include <iostream>
#include <string>
#include <cctype>
#include <cassert>

using namespace std;

string Str;
unsigned int cur = 0;

int digit();
int number();
int term();
int facter();
int expression();

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cur = 0;
        cin >> Str;
        Str.resize(Str.size()-1);
        int ans = expression();
        cout << ans << endl;
    }
    return 0;
}

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

int number()
{
    int n = digit();
    while(cur < Str.size() && isdigit(Str[cur])) n = n*10 + digit();
    return n;
}

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

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

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

C++: #include <bits/stdc++.h>

class Solve {
private:
	std::string inputStr;

	int64_t calcAdd(int& s_i)
	{
		int64_t ret{calcMulti(s_i)};
		while (inputStr[s_i] == '+' || inputStr[s_i] == '-')
		{
			char ope{inputStr[s_i]};
			s_i++;
			if (ope == '+') ret += calcMulti(s_i);
			else ret -= calcMulti(s_i);
		}
		return ret;
	}

	int64_t calcMulti(int& s_i)
	{
		int64_t ret{calcNum(s_i)};
		while (inputStr[s_i] == '*' || inputStr[s_i] == '/')
		{
			char ope{inputStr[s_i]};
			s_i++;
			if (ope == '*') ret *= calcNum(s_i);
			else ret /= calcNum(s_i);
		}
		return ret;
	}

	int64_t calcNum(int& s_i)
	{
		int64_t ret{};
		if (inputStr[s_i] == '(')
		{
			s_i++;
			ret = calcAdd(s_i);
			s_i++;
		}
		else
		{
			while (isdigit(inputStr[s_i]))
			{
				ret = 10 * ret + inputStr[s_i] - '0';
				s_i++;
			}
		}
		return ret;
	}

public:
	bool is_last_query{};
	Solve()
	{
		std::cin >> inputStr;
		int s_i{};
		printf("%lld\n", calcAdd(s_i));
	}
};

int main()
{
	int N;
	scanf("%d", &N);
	for (int i{}; i < N; i++)
		Solve();

	return 0;
}

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;
}