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

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef string::const_iterator State;
class ParseError {};

void consume(State &begin, char expected);
int factor(State &begin);
int expression(State &begin);
int term(State &begin);
int number(State &begin);

void consume(State &begin, char expected) {
    if (*begin == expected) {
        begin++;
    } else {
        cerr << "Expected '" << expected << "' but got '" << *begin << "'"
            << endl;
        cerr << "Rest string is '";
        while (*begin) {
            cerr << *begin++;
        }
        cerr << "'" << endl;
        throw ParseError();
    }
}

int factor(State &begin) {
    if (*begin == '(') {
        consume(begin, '(');
        int ret = expression(begin);
        consume(begin, ')');
        return ret;
    } else {
        return number(begin);
    }
}

// ?????????????????????????????????????????????????????????????????????
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 term(State &begin) {
    int ret = factor(begin);

    for (;;) {
        if (*begin == '*') {
            begin++;
            int a = factor(begin);
            ret *= a;
        } else if (*begin == '/') {
            begin++;
            ret /= factor(begin);
        } else {
            break;
        }
    }

    return ret;
}

// ??°??????????????????????????????????????°????????????
int number(State &begin) {
    int ret = 0;

    while (isdigit(*begin)) {
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }

    return ret;
}

int main() {
    int N;
    cin >> N;
    cin.ignore();
    for (int i = 0; i < N; i++) {
        string s;
        getline(cin, s);

        State begin = s.begin();
        int ans = expression(begin);
        consume(begin, '=');
        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <cctype>
#include <cassert>
#include <algorithm>
using namespace std;
size_t cur;
string s;

int expression();

int digit(){
  assert(cur < s.size());
  return s[cur++] - '0';
}
int number(){
  int n = 0.0;
  assert(cur < s.size());
  while(cur < s.size() && isdigit(s[cur])){
    n = n * 10 + digit();
  }
  return n;
}

int factor(){
  assert(cur < s.size());
  if(isdigit(s[cur])){
    return number();
  }else{
    cur++;
    int a = expression();
    assert(s[cur] == ')');
    cur++;
    return a;
  }
}

int term(){
  assert(cur < s.size());
  int a = factor();
    while(cur < s.size() && (s[cur] == '*' || s[cur] == '/')){
    char op = s[cur++];
    int b = factor();
    if(op == '*') a *= b; else a /= b;
  }
  return a;
}

int expression(){
  assert(cur < s.size());
  int a = term();
  while(cur < s.size() && (s[cur] == '-' || s[cur] == '+')){
    char op = s[cur++];
    int b = term();
    if(op == '-') a -= b; else a += b;
  }
  return a;
}

int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cur = 0;
    cin >> s;
    cout << expression() << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
 
using namespace std;
 
int expression();
int term();
int factor();
int number();
 
int now;
string s;
 
int expression(){
    int res=term();
        while(true){
        if(s[now]=='+')now++,res+=term();
        else if(s[now]=='-')now++,res-=term();
        else break;
    }
    return res;
}
 
int term(){
    int res=factor();
    while(true){
        if(s[now]=='*')now++,res*=factor();
        else if(s[now]=='/')now++,res/=factor();
        else break;
    }
    return res;
}
 
int factor(){
    int res=0;
    if(s[now]=='('){
        now++;
        res=expression();
        now++;
    }
    else return number();
     
    return res;
}
 
int number(){
    int res=0;
    while('0'<=s[now] && s[now]<='9'){
        res*=10;
        res+=s[now++]-'0';
    }
    return res;
}
 
 
int main(void){
    int n;
    cin >> n;
     
    while(n--){
        cin >> s;
        now=0;
        cout << expression() << endl;
    }
     
    return 0;
}

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

void select_cal(char c, int *tmp, int val){

	if(c == '+') *tmp += val;
	else if(c == '-') *tmp -= val;
	else if(c == '*') *tmp = floor(*tmp * val);
	else if(c == '/' && val != 0) *tmp = floor(*tmp / val);

}

int calculation(string str, int len, int begin){

	int ans, tmp, cnt, val;
	char c;
	
	ans = 0;
	tmp = 0;
	c = '+';

	for(int i=begin; i<len; i++){
		if(str[i] == '+' || str[i] == '-'){
			ans += tmp;
			tmp = 0;
			c = str[i];
		}
		else if(str[i] == '*' || str[i] == '/'){
			c = str[i];
		}
		else if(str[i] == '('){
			select_cal(c, &tmp, calculation(str, len, i+1));
			cnt = 1;
			do{
				i++;
				if(str[i] == '(') cnt++;
				else if(str[i] == ')') cnt--;
			}while(cnt != 0);
		}
		else if(str[i] == ')' || str[i] == '='){
			break;
		}
		else {
			cnt = 1;
			while(str[i+cnt] >= '0' && str[i+cnt] <= '9'){
				cnt++;
			}
			val = 0;
			for(int j=0; j<cnt; j++){
				val += (str[i+cnt-j-1] - '0') * pow(10, j);
			}
			select_cal(c, &tmp, val);
		}
	}
	ans += tmp;

	return ans;

}

int main(){

	int n;
	string str;
	
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> str;
		cout << calculation(str, str.length(), 0) << endl;
	}

	return 0;

}