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 <bits/stdc++.h>
 
using namespace std;
 
typedef string::const_iterator State;
class ParseError {};
 
typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()
 
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;
 
int expression(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 = factor(begin);
 
    for (;;) {
        if (*begin == '*') {
            begin++;
            ret *= factor(begin);
        } else if (*begin == '/') {
            begin++;
            ret /= factor(begin);
        } else {
            break;
        }
    }
    return ret;
}
 
int expression(State &begin) {
    int ret = term(begin);
 
    for (;;) {
        if (*begin == '+') {
            begin++;
            ret += term(begin);
        } else if (*begin == '-') {
            begin++;
            ret -= term(begin);
        } else {
            break;
        }
    }
 
    return ret;
}
 
int factor(State &begin) {
    if (*begin == '(') {
        begin++; // '('?????£???????´\????????£????´???£??????°?????£?????????£?????
        int ret = expression(begin);
        begin++; // ')'?????£???????´\????????£????´???£??????°?????£?????????£?????
        return ret;
    } else {
        return number(begin);
    }
}
 
int main(void) {
    int N;
    cin >> N;
    cin.ignore();
    for (int i = 0; i < N; i++) {
        string s;
        getline(cin, s);
        State begin = s.begin();
        cout << expression(begin) << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int expr(const string &s, int &pos);
int term(const string &s, int &pos);
int factor(const string &s, int &pos);
int number(const string &s, int &pos);

int expr(const string &s, int &pos) {
  auto res = term(s, pos);
  while ((pos < s.size()) and (s[pos] == '+' or s[pos] == '-')) {
    auto op = s[pos++];
    if (op == '+') {
      res += term(s, pos);
    } else {
      res -= term(s, pos);
    }
  }
  return res;
}

int term(const string &s, int &pos) {
  auto res = factor(s, pos);
  while ((pos < s.size()) and (s[pos] == '*' or s[pos] == '/')) {
    auto op = s[pos++];
    if (op == '*') {
      res *= factor(s, pos);
    } else {
      res /= factor(s, pos);
    }
  }
  return res;
}

bool is_digit(char ch) {
  return '0' <= ch and ch <= '9';
}

int factor(const string &s, int &pos) {
  if (is_digit(s[pos])) {
    return number(s, pos);
  }
  assert(s[pos++] == '(');
  auto res = expr(s, pos);
  assert(s[pos++] == ')');
  return res;
}

int number(const string &s, int &pos) {
  int ret = 0;
  while (pos < s.size() and is_digit(s[pos])) {
    ret = ret * 10 + (s[pos++] - '0');
  }
  return ret;
}

int main() {

  int n;
  cin >> n;
  cin.ignore();
  
  while (n--) {
    string s;
    getline(cin, s);
    s.pop_back();
    // <expr> ::= <term> [('+'|'-') <term>]*
    // <term> ::= <factor> [('*'|'/') <factor>]*
    // <factor> ::= <number> | '(' <expr> ')'
    // <number> ::= 123 とか
    int pos = 0;
    auto res = expr(s, pos);
    cout << res << endl;
  }

  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

long long int calc(string ex){
	long long int str,cnt,ans=0,now=0,add=1,n=ex.length(),i;
	bool sus=false,minus=false;
	char pm='+',md='*';
	for(i=0; i<n; i++){
		if(sus){
			if(ex[i]=='('){
				cnt++;
			}else if(ex[i]==')'){
				cnt--;
				now = calc(ex.substr(str,i-str));
				sus = false;
			}
		}else{
			switch(ex[i]){
				case '(':
					str = i+1;
					cnt = 1;
					sus = true;
					break;
				case '-':
					if(i==0 || ex[i-1]== '+' || ex[i-1]== '-' || ex[i-1]== '*' || ex[i-1]== '/'){
						minus = true;
						break;
					}
				case '+':
					if(minus){
						now *= -1;
						minus = false;
					}
					if(md == '*'){
						add *= now;
					}else{
						add /= now;
					}
					if(pm == '+'){
						ans += add;
					}else{
						ans -= add;
					}
					pm = ex[i];
					md = '*';
					now = 0;
					add = 1;
					break;
				case '*':
				case '/':
					if(minus){
						now *= -1;
						minus = false;
					}
					if(md == '*'){
						add *= now;
					}else{
						add /= now;
					}
					md = ex[i];
					now = 0;
					break;
				case '0':
				case '1':
				case '2':
				case '3':
				case '4':
				case '5':
				case '6':
				case '7':
				case '8':
				case '9':
					now *= 10;
					now += ex[i]-'0';
					break;
				default:
					break;
			}
		}
	}
	if(minus){
		now *= -1;
		minus = false;
	}
	if(md == '*'){
		add *= now;
	}else{
		add /= now;
	}
	if(pm == '+'){
		ans += add;
	}else{
		ans -= add;
	}
	return ans;
}

int main(void){
	int n,i;
	long long int ans;
	string str;
	cin >> n;
	for(i=0; i<n; i++){
		cin >> str;
		ans = calc(str);
		cout << ans << endl;
	}
	return 0;
}