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 <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int expr(string& s, int& i);
int term(string& s, int& i);
int factor(string& s, int& i);
int number(string& s, int& i);

int expr(string& s,int& i) {
	int a = term(s, i);
	while (s[i] == '+' || s[i] == '-') {
		char op = s[i];
		i++;
		int b = term(s, i);
		if (op == '+') {
			a = a+b;
		}
		else {
			a = a - b;
		}
	}
	return a;
}

int term(string& s, int& i) {
	int a = factor(s, i);
	while (s[i] == '*' || s[i] == '/') {
		char op = s[i];
		i++;
		int b = factor(s, i);
		if (op == '*') {
			a = a*b;
		}
		else {
			a = a / b;
		}
	}
	return a;
}

int factor(string& s, int& i) {
	if (isdigit(s[i])) {
		int a = number(s, i);
		return a;
	}
	else {
		i++;//(
		int a = expr(s, i);
		i++;//)
		return a;
	}
}

int number(string& s, int& i) {
	int a = s[i]-'0';
	i++;
	while (isdigit(s[i])) {
		a = a * 10 + (s[i] - '0');
		i++;
	}
	return a;
}

int main()
{
	int n;
	cin >> n;
	REP(j, n) {
		string ss;
		cin >> ss;
		int k = 0;
		cout << expr(ss, k) << endl;
	}

}

C++: #include <iostream>
#include <cassert>
#include <cctype>
using namespace std;
string S;
int cur;
char readchar()
{
    assert(cur<S.size());
    char ret=S[cur];
    cur++;
    return ret;
}
char peek()
{
    assert(cur<S.size());
    return S[cur];
}
int digit()
{
    assert(isdigit(peek()));
    int n=readchar()-'0';
    return n;
}
int number()
{
    int n=digit();
    while(cur < S.size() && isdigit(peek()))
    {
        n=n*10+digit();
    }
    return n;
}
//-----------------
int factor();
int term()
{
    int a=factor();
    while(cur<S.size()&&(peek()=='*'||peek()=='/'))
    {
        char op=readchar();
        int b=factor();
        if(op=='*')
            a*=b;
        else
            a/=b;
    }
    return a;
}

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

int factor()
{
    if(peek()!='(')return number();
    cur+=1;
    int n=expression();
    assert(peek()==')');
    cur+=1;
    return n;
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cur=0;
        cin>>S;
        cout<<expression()<<endl;
        S.erase(S.begin(),S.end());
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int calc(string s){
    while(1){
        vector<pair<int, int>> vv;
        int depth = 0;
        for(int i = 0; i < s.size(); i++){
            if(s[i] == '('){
                vv.push_back(pair<int, int>(i, ++depth));
            }else if(s[i] == ')'){
                --depth;
            }
        }
        if(vv.size() != 0){
            sort(vv.begin(), vv.end(), [](auto a, auto b){return a.second != b.second ? a.second > b.second : a.first < b.first;});
            int pos;
            for(pos = vv[0].first; s[pos] != ')'; pos++);
            int ret = calc(s.substr(vv[0].first + 1, pos - vv[0].first - 1));
            string t = s.substr(0, vv[0].first) + to_string(ret) + s.substr(pos + 1);
            s = t;
            cout << s << endl;
        }else{
            while(1){
                map<char, vector<int>> m;
                for(int i = 0; i < s.size(); i++){
                    if(s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/') m[s[i]].push_back(i);
                }
                vector<int> v;
                if(m.find('*') != m.end() || m.find('/') != m.end()){
                    for(int pos : m['*']) v.push_back(pos);
                    for(int pos : m['/']) v.push_back(pos);
                }else{
                    for(int pos : m['+']) v.push_back(pos);
                    for(int pos : m['-']) v.push_back(pos);
                }
                if(v.size() == 0 || (v.size() == 1 && v[0] == 0)) break;
                sort(v.begin(), v.end());
                string t;
                int pos = v[0];
                string num[2];
                int tmp;
                for(int j = pos - 1; 0 <= j; j--){
                    if('0' <= s[j] && s[j] <= '9'){
                        num[0] += s[j];
                    }else{
                        for(int k = 0; k <= j; k++){
                            t += s[k];
                        }
                        break;
                    }
                }
                for(int j = pos + 1; j <= s.size(); j++){
                    if('0' <= s[j] && s[j] <= '9'){
                        num[1] += s[j];
                    }else{
                        tmp = j;
                        break;
                    }
                }
                int add;
                switch(s[pos]){
                    case '+':
                        add = stoi(num[0]) + stoi(num[1]);
                        break;
                    case '-':
                        add = stoi(num[0]) - stoi(num[1]);
                        break;
                    case '*':
                        add = stoi(num[0]) * stoi(num[1]);
                        break;
                    case '/':
                        add = stoi(num[0]) / stoi(num[1]);
                        break;
                }
                t += to_string(add);
                for(int j = tmp; j < s.size(); j++) t += s[j];
                s = t;
            }
            return stoi(s);
        }
    }
}
    
int main(){
    int N;
    cin >> N;
    for(int pomu = 0; pomu < N; pomu++){
        string s;
        cin >> s;
        s = s.substr(0, s.size() - 1);
        cout << calc(s) << endl;
    }
    return 0;
}