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, long long a, bool b){

	std::string res;

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

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

	return res;
}

long long tolong long(std::string str){

	long long res;
	std::stringstream z;

	z << str;
	z >> res;

	return res;

}

std::string tostring(long long a){

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

	z << a;
	z >> str;

	return str;

}

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

	long long a, b, c;

	a = tolong long(lhs);
	b = tolong long(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){

	long long res = 0;

	for (long long i = 0, j = 0, c = 0; i < v.size(); i++){

		if (v[i] == "("){
			if (c == 0)j = i;
			c++;
		}

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


	for (long long 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 (long long 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 (long long i = 0; i < v.size(); i++){
		if (v[i] != "T")res = tolong long(v[i]);
	}
	return tostring(res);

}


long long main(){

	long long n;
	std::cin >> n;

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

		std::string str;

		std::cin >> str;

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

		for (long long 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 << keisan2(v) << std::endl;
	}

	return 0;
}