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 (unsigned long long i = a - 1; i >= 0; i--){
			if (v[i] != "T"){
				res = v[i];
				v[i] = "T";
				break;
			}
		}
	}

	if (!b){
		for (unsigned 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(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(lhs);
	b = tolong(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 (unsigned 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 (unsigned long long p = j + 1; p < i; p++)w.push_back(v[p]);
				v[j] = keisan2(w);
				for (unsigned long long p = j + 1; p <= i; p++)v[p] = "T";
			}
		}
	}


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

}


int 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 (unsigned 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;
}

C++: #include <iostream>
#include <string>
using namespace std;
string str;
int p;

int exp();
int factor();
int term();

int factor() {
  int num=0;
  while('0' <= str[p] && str[p] <= '9') {
    num*=10;
    num += str[p] - '0';
    p++;
  }

  else if (str[p] == '('){
    p++;
    num = exp();
  }
  if(str[p] == ')')  p++;

   
  return num;
}

int term(){
 int val = factor();
  while(str[p] == '*' || str[p] == '/') {
    if(str[p] == '*') {
      p++;
      val *= factor();
    } else if(str[p] == '/'){
      p++;
      val /= factor();
    }
  }

  return val;
}
 
int exp() {
  int val = term();
  while(str[p] == '+' || str[p] == '-') {
    if(str[p] == '+') {
      p++;
      val += term();
    } else if(str[p] == '-'){
      p++;
      val -= term();
    }
  }

  return val;
}

int main() {
  int n;

  cin >> n;
  
  for(int i=0;i<n;i++) {
    p = 0;
  cin >> str;
  cout << exp() << endl;
  }
  return 0;
}