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 <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int calculate(const char* str, int begin, int end);
int getNumber(const char* str, int begin, int end)
{
	bool minus = false;
	
	if(str[begin] == '('){
		int depth = 1;
		int index;
		for(index=begin+1; depth; ++index){
			depth += str[index] == '(';
			depth -= str[index] == ')';
		}
		return calculate(str, begin+1, index-1);
	}
	else if(str[begin] == '-'){
		minus = true;
		++begin;
	}else if(str[begin] == '+')
		++begin;
	
	int num = 0;
	for(int i=begin; i<end && isdigit(str[i]); ++i)
		num = num*10 + str[i] - '0';
	if(minus)
		num *= -1;
	return num;
}

int getTerm(const char* str, int begin, int end)
{
	int num = 1;
	int index = begin;
	int depth = 0;
	char operation = '*';
	for(int i=begin; i<=end; ++i){
		if(i<end){
			depth += str[i] == '(';
			depth -= str[i] == ')';
		}
		
		if(depth == 0){
			if(i==end || str[i] == '*' || str[i] == '/'){
				if(operation == '*')
					num *= getNumber(str, index, i);
				if(operation == '/')
					num /= getNumber(str, index, i);
				if(i<end)
					operation = str[i];
				index = i+1;
			}
		}
	}

	return num;
}

int calculate(const char* str, int begin, int end)
{
	int num = 0;
	int index = begin;
	int depth = 0;
	char operation = '+';
	for(int i=begin; i<=end; ++i){
		if(i<end){
			depth += str[i] == '(';
			depth -= str[i] == ')';
		}
		if(depth == 0){
			if(i==end || str[i] == '+' || str[i] == '-'){
				if(operation == '+')
					num += getTerm(str, index, i);
				if(operation == '-')
					num -= getTerm(str, index, i);
				if(i<end)
					operation = str[i];
				index = i+1;
			}
		}
	}
	
	return num;
}

int main()
{
	int n;
	scanf("%d", &n);
	rep(i, n){
		char str[128];
		scanf("%s", str);
		printf("%d\n", calculate(str, 0, strlen(str)-1));
	}

	return 0;
}

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

string s;

int single(int& pos);

int figure(int& pos);

int solve(int& pos);

int main(){
	int T;
	cin>>T;
	for(int i = 0; i < T; i++){
		cin>>s;
		int pos = 0;
		cout<<solve(pos)<<endl;
	}
	
	return 0;
}

int single(int& pos){//??°??????????????????????????¢??°
	if(s[pos]!='('){
		int res = 0;
		while('0'<=s[pos] && s[pos]<='9'){
			res *= 10;
			res += s[pos]-48;
			pos++;
		}
		return res;
	}else{
		return solve(++pos);
	}
}

int figure(int& pos){//????????????????????????????????¢??°
	int res = single(pos);
	while(1){
		if(s[pos]=='*'){
			res *= single(++pos);
		}else if(s[pos]=='/'){
			res /= single(++pos);
		}else {
			return res;
		}
	}
}

int solve(int& pos){//?????¨???????¨????????????¢??°(????????????????¨?????????????????????¨?????????)
	int res = figure(pos);
	while(s[pos]!='=' && s[pos]!=')'){
		if(s[pos]=='+') res += figure(++pos);
		else if(s[pos]=='-') res -= figure(++pos);
	}
	pos++;
	return res;
}

C++: #include<iostream>
#include<string>
#include<sstream>
using namespace std;

typedef long long ll;

string s;

ll stol(string str){
  stringstream ss(str);
  ll n;
  ss >> n;
  return n;
}

ll parse(int l, int r){
  int n = 0, i;
  for(int i=r-1;i>=l;i--){
    if(s[i] == ')')n++;
    if(s[i] == '(')n--;
    if(!n){
      if(s[i] == '+')return parse(l,i) + parse(i+1,r);
      if(s[i] == '-')return parse(l,i) - parse(i+1,r);
    }
  }
  for(int i=r-1;i>=l;i--){
    if(s[i] == ')')n++;
    if(s[i] == '(')n--;
    if(!n){
      if(s[i] == '*')return parse(l,i) * parse(i+1,r);
      if(s[i] == '/')return parse(l,i) / parse(i+1,r);
    }
  }

  if(s[l] == '(' && s[r-1] == ')')return parse(l+1,r-1);
  return stol( s.substr(l,r-l) );
}

int main(){
  int n;
  cin >> n;
  while(n--){
    cin >> s;
    cout << parse(0,(int)s.size()-1) << endl;
  }
}

C++: #include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

// <expr>   ::= <term> [ ('+'|'-') <term> ]*
// <term>   ::= <factor> [ ('*'|'/') <factor> ]*
// <factor> ::= <number> | '(' <expr> ')'
// <number> :== ???????????°

int expr(int& pos);
int term(int& pos);
int factor(int& pos);
int number(int& pos);

string s;

int expr(int& pos){
    int res = term(pos);
    while(s[pos] == '+' || s[pos] == '-'){
        if(s[pos] == '+'){
            res += term(++pos);
        }else{
            res -= term(++pos);
        }
    }
    return res;
}

int term(int& pos){
    int res = factor(pos);
    while(s[pos] == '*' || s[pos] == '/'){
        if(s[pos] == '*'){
            res *= factor(++pos);
        }else{
            res /= factor(++pos);
        }
    }
    return res;
}

int factor(int& pos){
    if(isdigit(s[pos])) return number(pos);
    pos++;  //'('?????¨??°???
    int res = expr(pos);
    pos++;  //')'?????¨??°???
    return res;
}

int number(int& pos){
    string res;
    while(isdigit(s[pos])){
        res.pb(s[pos++]);
    }
    return stoi(res);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        cin >> s;
        int pos = 0;
        cout << expr(pos) << "\n";
    }
    return 0;
}