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 <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;
typedef string::const_iterator iter;

int expr(iter &p);
int term(iter& p);
int factor(iter& p);
int number(iter& p);

int expr(iter& p) {
    int r = term(p);
    while(true) {
        if(*p == '+') {
            ++p;
            int rs = term(p);
            r += rs;
        }
        else if(*p == '-') {
            ++p;
            int rs = term(p);
            r -= rs;
        }
        else {
            break;
        }
    }
    return r;
}

int term(iter& p) {
    int r = factor(p);
    while(true) {
        if(*p == '*') {
            ++p;
            int rs = term(p);
            r *= rs;
        }
        else if(*p == '/') {
            ++p;
            int rs = term(p);
            r /= rs;
        }
        else {
            break;
        }
    }
    return r;
}

int factor(iter& p) {
    if(*p == '(') {
        ++p; // skip (
        int r = expr(p);
        ++p; // skip )
        return r;
    }
    
    return number(p);
}

int number(iter& p) {
    int r = 0;
    while(isdigit(*p)) {
        r *= 10;
        r += *p -'0';
        p++;
    }
    return r;
}

int main() {
    int n; cin >> n;
    while(n--) {
        string s; cin >> s;
        iter it = s.begin();
        int res = expr(it);
        cout << res << endl;
    }
}
s

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long ll;

pair<ll, const char*> expr(const char*);
pair<ll, const char*> term(const char*);
pair<ll, const char*> fact(const char*);

pair<ll, const char*> expr(const char* p) {
  pair<ll, const char*> lhs = term(p);
  ll ret = lhs.first;
  const char* q = lhs.second;
  while (*q == '+' || *q == '-') {
    pair<ll, const char*> rhs = term(q + 1);
    if (*q == '+') { ret += rhs.first; }
    else { ret -= rhs.first; }
    q = rhs.second;
  }
  return make_pair(ret, q);
}

pair<ll, const char*> term(const char* p) {
  pair<ll, const char*> lhs = fact(p);
  ll ret = lhs.first;
  const char* q = lhs.second;
  while (*q == '*' || *q == '/') {
    pair<ll, const char*> rhs = fact(q + 1);
    if (*q == '*') { ret *= rhs.first; }
    else { ret /= rhs.first; }
    q = rhs.second;
  }
  return make_pair(ret, q);
}

pair<ll, const char*> fact(const char* p) {
  if (*p == '(') {
    pair<ll, const char*> inside = expr(p + 1);
    return make_pair(inside.first, inside.second + 1);
  } else {
    ll ret = 0;
    const char* q;
    for (q = p; '0' <= *q && *q <= '9'; ++q) {
      ret *= 10;
      ret += *q - '0';
    }
    return make_pair(ret, q);
  }
}

int main() {
  int T; scanf("%d", &T);
  while (T--) {
    char buffer[128]; scanf("%s", buffer);
    pair<ll, const char*> ret = expr(buffer);
    printf("%lld\n", ret.first);
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int calc(char *s, int &i){
  int ret = 0;
  bool flag = i >= 0 && s[i-1] == '(';
  
  for(;s[i];){
    
    if(s[i] == ')'){
      if(flag) i++;
      return ret;
    }
    
    if(s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/'){

      i++;
      
      if(s[i] == '('){
        i++;

        if(i-2 < 0) ret += calc(s,i);
        if(s[i-2] == '+') ret += calc(s,i);
        if(s[i-2] == '-') ret -= calc(s,i);
        if(s[i-2] == '*') ret *= calc(s,i);
        if(s[i-2] == '/') ret /= calc(s,i);

        continue;
      }

            
      if(s[i-1] == '+') ret += calc(s,i);
      if(s[i-1] == '-') ret -= calc(s,i);
      
    }else{
      int start = i-1;
      int sum = 0;
      
      while(!(s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/' || s[i] == '\0' || s[i] == ')')){
        sum *= 10;
        sum += s[i] - '0';
        i++;
      }

      if(start < 0){
        ret += sum;
      }else{
        if(s[start] == '(') ret += sum;
        if(s[start] == '+') ret += sum;
        if(s[start] == '-') ret += sum;
        if(s[start] == '*') ret *= sum;
        if(s[start] == '/') ret /= sum;
      }
    }
  }

  return ret;
}


int main(){
  char s[SIZE];
  int t = 0;

  int n;

  scanf("%d",&n);

  while(n--){
    t = 0;
    scanf("%s",s);

    s[strlen(s)-1] = '\0';
    
    printf("%d\n",calc(s,t));
  }
  
  return 0;
}