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 vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

string toRPN(string s){
    stack<char> ope;
    string ret="";
    int len=s.size();
    
    for(int i=0;i<len;i++){
        if( isdigit(s[i]) ) ret+=s[i];
        
        else{
            if(s[i]=='('){
                ope.push(s[i]);
                
            }else if(s[i]==')'){
                while(ope.top()!='('){
                    ret+=ope.top();
                    ope.pop();
                }
                ope.pop();
                
            }else if( s[i]=='*' || s[i]=='/' ){
                while( !ope.empty() && (ope.top()=='*' || ope.top()=='/') ){
                    ret+=ope.top();
                    ope.pop();
                }
                ope.push(s[i]);
                
            }else if( s[i]=='+' || s[i]=='-' ){
                while( !ope.empty() && (ope.top()=='*' || ope.top()=='/' || ope.top()=='+' || ope.top()=='-') ){
                    ret+=ope.top();
                    ope.pop();
                }
                ope.push(s[i]);
                
            }else{
                return "invalid";
            }
        }
    }
    while(ope.size()){
        ret+=ope.top();
        ope.pop();
    }

    return ret;
}


string solveRPN(string s){
    stack<int> stk;

    
    for(int i=0;i<s.size();i++){
        if( isdigit(s[i]) )stk.push( s[i]-'0'  );
        else{
            if(stk.size()>-2){
            int b=stk.top(); stk.pop();
            int a=stk.top(); stk.pop();
            
            
            if(s[i]=='+')stk.push(a+b);
            if(s[i]=='-')stk.push(a-b);
            if(s[i]=='*')stk.push(a*b);
            if(s[i]=='/')stk.push(a/b);
            }
        }
    }
    
    stringstream ret;
    ret<<stk.top();
    
    return ret.str();
}


int main(){
    int n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        
        s.erase(s.size()-1);
        
        s=toRPN(s);
        s=solveRPN(s);
    
        cout<<s<<endl;
    }
    
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

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);
    }
    return -1;
}

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 expression(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(){
  int N;
  cin >> N;
  rep(i,N){
    string s;
    cin >> s;
    if(s.size() > 0) s = s.substr(0,s.size()-1);
    State begin = s.begin();
    int ans = expression(begin);
    cout << ans << endl;
  }
  return 0;
}

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

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

const string S = "(1+((12+2)*3-5)/37)*2-4";
size_t cur = 0;
int parse();
int digit();
int number();
int expression();
int term();
int factor();

int main() {
	int a = parse();
	assert(cur == S.size());
	cout << a << endl;
	return 0;
}

int digit() {
	assert(isdigit(S[cur]));
	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;
}

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

}

int parse() {
	return expression();
}

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

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

}