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

std::string find(std::vector<std::string>&v, int a, bool b){

	std::string res;

	if (b){
		for (int i = a - 1; i >= 0; i--){
			if (v[i] != "T"){
				res = v[i];
				v[i] = "T";
				break;
			}
		}
	}

	if (!b){
		for (int i = a + 1; i < v.size(); i++){
			if (v[i] != "T"){
				res = v[i];
				v[i] = "T";
				break;
			}
		}
	}

	return res;
}

int toint(std::string str){

	int res;
	std::stringstream z;

	z << str;
	z >> res;

	return res;

}

std::string tostring(int a){

	std::string str;
	std::stringstream z;

	z << a;
	z >> str;

	return str;

}

std::string keisan(std::string lhs, std::string rhs, int t){

	int a, b, c;

	a = toint(lhs);
	b = toint(rhs);

	if (t == 1)c = a + b;
	if (t == 2)c = a - b;
	if (t == 3)c = a * b;
	if (t == 4)c = a / b;

	return tostring(c);

}

std::string keisan2(std::vector<std::string> &v){

	int res = 0;

	for (int i = 0, j = 0, k = 0; i < v.size(); i++){
		if (v[i] == "(")j = i, k++;
		if (v[i] == ")"){
			k--;
			if (k == 0){
				std::vector<std::string>w;
				for (int p = j + 1; p < i; p++)w.push_back(v[p]);
				v[j] = keisan2(w);
				for (int p = j + 1; p <= i; p++)v[p] = "T";
			}
		}
	}


	for (int i = 0; i < v.size(); i++){
		if (v[i] == "*"){
			v[i - 1] = keisan(find(v, i, 1), find(v, i, 0), 3);
			v[i] = v[i + 1] = "T";
		}
		if (v[i] == "/"){
			v[i - 1] = keisan(find(v, i, 1), find(v, i, 0), 4);
			v[i] = v[i + 1] = "T";
		}
	}

	for (int i = 0; i < v.size(); i++){
		if (v[i] == "+"){
			v[i - 1] = keisan(find(v, i, 1), find(v, i, 0), 1);
			v[i] = v[i + 1] = "T";
		}
		if (v[i] == "-"){
			v[i - 1] = keisan(find(v, i, 1), find(v, i, 0), 2);
			v[i] = v[i + 1] = "T";
		}
	}

	v[v.size() - 1] = "T";
	for (int i = 0; i < v.size(); i++)if (v[i] != "T")res = toint(v[i]);

	return tostring(res);

}


int main(){

	int n;
	std::cin >> n;

	for (int i = 0; i < n; i++){

		std::string str;

		std::cin >> str;

		std::vector<std::string> v;

		for (int i = 0, j = 0; i < str.size(); i++){

			if (!(str[i] >= '0'&&str[i] <= '9')){
				if (i - j > 0)v.push_back(str.substr(j, i - j));
				v.push_back(str.substr(i, 1));
				j = i + 1;
			}
		}

		std::cout << toint(keisan2(v)) << std::endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <stack>
#include <map>
#include <cstdlib>
#include <cctype>
#include <cstdio>
#include <cstring>

using namespace std;

int str2arr(char s[], string A[]) {
    bool flag = true;
    string t;
    int l = strlen(s);
    int n = 0;
    for (int i = 0; i < l; i++) {
        if (isdigit(s[i]) && flag) {
            t = "";
            int j = 0;
            while (isdigit(s[i+j])) {
                t += s[i+j];
                if (i+j == l-1)
                    break;
                j++;
            }
            A[n++] = t;
            flag = false;
        }
        else if (!isdigit(s[i])) {
            A[n++] = s[i];
            flag = true;
        }
    }
    return n;
}

int Generate_RPN(int n, string A[], string B[]) {
    map<string, int> table;
    table["*"] = 1;
    table["/"] = 1;
    table["+"] = 0;
    table["-"] = 0;
    table["("] = -1;
    table[")"] = -1;
    stack<string> S;
    int j = 0;

    for (int i = 0; i < n; i++) {
        if (isdigit(A[i][0])) {
            B[j++] = A[i];
        }

        else if (A[i] == "(")
            S.push(A[i]);

        else if (A[i] == ")") {
            while (S.top() != "(") {
                B[j++] = S.top();
                S.pop();
            }
            S.pop();
        }
        else {
            while ((!S.empty()) && (table[S.top()] >= table[A[i]])) {
                B[j++] = S.top();
                S.pop();
            }
            S.push(A[i]);
        }
    }
    while (!S.empty()) {
        B[j++] = S.top();
        S.pop();
    }
    return j;
}

void calculate(int n, string s[]) {
    stack<double> St;
    double a, b;

    for (int i = 0; i < n; i++) {
        if (s[i] == "+") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a+b);
        }
        else if (s[i] == "-") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a-b);
        }
        else if (s[i] == "*") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a*b);
        }
        else if (s[i] == "/") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a/b);
        }
        else {
            St.push(atoi(s[i].c_str()));
        }
    }
    cout << int(St.top()) << endl;
}

int main()
{
    int n, l, t;
    string A[101], B[101];
    char s[101];

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%s", s);
        s[strlen(s)-1] = '\0';

        l = str2arr(s, A);
        t = Generate_RPN(l, A, B);

        calculate(t, B);
    }

    return 0;
}