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 <iostream>
#include <string>
#include <vector>

using namespace std;

int compute(string s) {
    int begin;
    int nest = 0;
    int n = 0;
    vector<int> children, children2;
    vector<char> operators, operators2;

    for (int i=0; i<(int)s.length(); i++) {
        if (s[i] == '(') {
            nest++;
            if (nest == 1) {
                begin = i+1;
            }
        }
        else if (s[i] == ')') {
            if (nest == 1) {
                string substr = s.substr(begin, i-begin);
                n = compute(substr);
            }
            nest--;
        }
        else if (nest == 0) {
            if ('0' <= s[i] && s[i] <= '9') {
                n *= 10;
                n += s[i]-'0';
            }
            else {
                children.push_back(n);
                operators.push_back(s[i]);
                n = 0;
            }
        }
    }
    children.push_back(n);
    if (operators.size() == 0) {
        return children[0];
    }
    children2.push_back(children[0]);
    for (int i=0; i<(int)operators.size(); i++) {
        if (operators[i] == '*') {
            children2[children2.size()-1] *= children[i+1];
        }
        else if (operators[i] == '/') {
            children2[children2.size()-1] /= children2[i+1];
        }
        else {
            children2.push_back(children[i+1]);
            operators2.push_back(operators[i]);
        }
    }
    n = children2[0];
    for (int i=0; i<(int)operators2.size(); i++) {
        if (operators2[i] == '+') {
            n += children2[i+1];
        }
        else {
            n -= children2[i+1];
        }
    }
    return n;
}

int main() {
    int n;
    string s;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> s;
        cout << compute(s.substr(0, s.length()-1)) << endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<string>
#include<cctype>
#include<iostream>
#include<algorithm>

using namespace std;

typedef string::const_iterator State;

int expr(State &begin);
int term(State &begin);
int number(State &begin);
int factor(State &begin);

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 expr(State &begin){
	int ret=factor(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=expr(begin);
		begin++;
		return ret;
	}else{
		return number(begin);
	}
}

int main(){
	int N;
	cin>>N;
	cin.ignore();
	for(int i=0;i<N;i++){
		string str;
		getline(cin,str);
		State begin=str.begin();
		int ans=expr(begin);
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(5)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<short, short> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int calc(string s)
{
	vi v;
	REP(i, s.size())
	{
		if (s[i] == '+') v.push_back(0);
		else if (s[i] == '-') v.push_back(1);
		else if (s[i] == '*') v.push_back(2);
		else if (s[i] == '/') v.push_back(3);
		else
		{
			int tmp = s[i] - '0';
			int t = i+1;
			while (isdigit(s[t]))
			{
				tmp = tmp * 10 + s[t] - '0';
				t++;
			}
			i = t - 1;
			v.push_back(tmp);
		}
	}

	while (v.size() > 1)
	{
		for (int i = 1; i < v.size();i+=2)
		{
			if (v[i]==2)
			{
				int tmp = v[i - 1] * v[i + 1];
				v[i - 1] = tmp;
				v.erase(v.begin() + i + 1);
				v.erase(v.begin() + i);
				goto next;
			}
			else if (v[i] == 3)
			{
				int tmp = v[i - 1] / v[i + 1];
				v[i - 1] = tmp;
				v.erase(v.begin() + i + 1);
				v.erase(v.begin() + i);
				goto next;
			}
		}
		for (int i = 1; i < v.size(); i += 2)
		{
			if (v[i] == 0)
			{
				int tmp = v[i - 1] + v[i + 1];
				v[i - 1] = tmp;
				v.erase(v.begin() + i + 1);
				v.erase(v.begin() + i);
				break;
			}
			else if (v[i] == 1)
			{
				int tmp = v[i - 1] - v[i + 1];
				v[i - 1] = tmp;
				v.erase(v.begin() + i + 1);
				v.erase(v.begin() + i);
				break;
			}
		next:;
		}
	}
	return v[0];
}

int solve(string s)
{
	while (1)
	{
		if (find(ALL(s), '(') == s.end())
		{
			return calc(s);
		}
		else
		{
			string tmp;
			REP(i, s.size())
			{
				if (s[i] != '(') tmp.push_back(s[i]);
				else
				{
					int j;
					for (j = s.size()-1;; j--)
					{
						if (s[j] == ')')
						{
							int t = solve(s.substr(i+1, j - i - 1));
							tmp += to_string(t);
							break;
						}
					}
					i = j;
				}
			}
			return solve(tmp);
		}
	}
	return 0;
}

int main()
{
	int sets;
	string s;
	cin >> sets;
	REP(set, sets)
	{
		cin >> s;
		s.pop_back();
		cout << solve(s) << endl;
	}
	return 0;

}