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 string::const_iterator State;
class ParseError {};
 
int term(State &begin);
int expression(State &begin);
int factor(State &begin);
int number(State &begin);
void consume(State &begin, char expected);
 
// 四則演算の式をパースして、その評価結果を返す。
// <四則演算の式> ::= <乗算除算の式> (+ or -) <乗算除算の式> (+ or -) ...
// <expr>   ::= <term> [ ('+'|'-') <term> ]*
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;
}
 
// 乗算除算の式をパースして、その評価結果を返す。
// <乗算除算の式> ::= <括弧か数> (* or /) <括弧か数> (* or /) ...
// <term>   ::= <factor> [ ('*'|'/') <factor> ]*
int term(State &begin){
    int ret = factor(begin);
    for(;;){
        if(*begin == '*'){
            begin++;
            ret *= factor(begin);
        }else if(*begin == '/'){
            begin++;
            ret /= factor(begin);
        }else{
            break;
        }
    }
    return ret;
}

// 括弧か数をパースして、その評価結果を返す。 
// <括弧か数> ::= '(' <四則演算の式> ')' or <数>
// <factor> ::= <number> | '(' <expr> ')'
int factor(State &begin){
    if(*begin == '('){
        begin++;
        int ret = expression(begin);
        begin++;
        return ret;
    }else{
        return number(begin);
    }
}
 
// 数字の列をパースして、その数を返す。
// <数> ::= ...
// <number> :== 1つ以上の数字
int number(State &begin){
    int ret = 0;
    while(isdigit(*begin)){
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }
    return ret;
}
 
int main(){
    int N;
    cin >> N;
    cin.ignore();
    for(int i = 0; i < N; i++){
        string s;
        getline(cin, s);
        State begin = s.begin();
        int ans = expression(begin);
        cout << ans << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
class Parser {
    string s;
    ll pos;
    ll E() {
        ll res = T();
        while (!end() && (nchar() == '+' || nchar() == '-')) {
            if (nchar() == '+') {
                read_char('+');
                res += T();
            }
            else {
                read_char('-');
                res -= T();
            }
        }
        return res;
    }
    ll T() {
        ll res = number();
        while (!end() && (nchar() == '*' || nchar() == '/')) {
            if (nchar() == '*') {
                read_char('*');
                res *= number();
            }
            else {
                read_char('/');
                res /= number();
            }
        }
        return res;
    }
    ll number() {
        if (nchar() == '(') {
            read_char('(');
            ll res = E();
            read_char(')');
            return res;
        }
        else {
            string res = "";
            while (!end() && isdigit(nchar())) {
                res += nchar();
                ++pos;
            }
            return stoll(res);
        }
    }
    bool end() {
        return nchar() == '=';
    }
    char nchar() {
        assert(pos < s.size());
        return s[pos];
    }
    void read_char(char c) {
        assert(!end() && nchar() == c);
        ++pos;
    }
public:
    Parser(const string& s) : s(s), pos(0) {}
    ll parse() {
        pos = 0;
        return E();
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll T; cin >> T;
    rep(t, T) {
        string s; cin >> s;
        cout << Parser(s).parse() << endl;
    }
}

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

string str;

int subj(int s, int e){
	int n = 0;
	for(int i = s;i < e;i++){
		if(str[i] == '(')n++;
		if(str[i] == ')'){if(n == 0)return i;n--;}
	}
}

int calc(int s, int e, int m){
	int p = 0;
	for(p = s;p < e && str[p] >= '0' && str[p] <= '9';p++);
	int a = atoi(str.substr(s, p-s).c_str());
	if(str[s] == '('){
		p = subj(s+1, e);
		a = calc(s+1, p, 0);p++;
		//cout << "p = " << s << p << " ";
	}
	if(m%10 == 1)a *= m/10;
	if(m%10 == 2)a = (m/10) / a;
	
	if(str[p] == '+')return a + calc(p+1, e, 0);
	if(str[p] == '-')return a - calc(p+1, e, 0);
	if(str[p] == '*')return calc(p+1, e, a*10+1);
	if(str[p] == '/')return calc(p+1, e, a*10+2);
	if(str[p] == '=' || str[p] == ')')return a;
	
	return 0;
}

int main(){
	int n;cin >> n;
	while(n--){
		cin >> str;
		cout << calc(0, str.size(), 0) << endl;
	}
	
	return 0;
}

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

string S;
size_t cur;

int parse();
int expression();

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 factor(){
  if(S[cur] != '(') return number();
  cur++;
  int n = expression();
  assert(S[cur] == ')');
  cur++;
  return n;
}

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 {
      assert(b != 0);
      a /= b;
    };
  }
  return a;
}


int expression(){
  int sum = term();
  while(S[cur] == '+' || S[cur] == '-'){
    char op = S[cur];
    cur++;
    int b = term();
    if (op == '+') sum += b;
    else sum -= b;
  }
  return sum;
}
int parse() { return expression(); }

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