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 <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <cctype>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

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

int number(State &begin);
int factor(State &begin);
int term(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 factor(State &begin) {
    if(*begin == '(') {
        begin++; // '(' ????£???°???
        int ret = expression(begin);
        begin++; // ')' ????£???°???
        return ret;
    }
    else return number(begin);
}

// ??????????????????????????????
int term(State &begin) {
    // ????????????????????¨????????£????????°??????????????§???????????????
    // begin ?????????????????°?????§???????????????
    int ret = factor(begin);

    while(1) {
        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);
    while(1) {
        if(*begin == '+') {
            begin++;
            ret += term(begin);
        }
        else if(*begin == '-') {
            begin++;
            ret -= term(begin);
        }
        else break;
    }
    return ret;
}

signed main() {
    int N; cin >> N;
    rep(i,0,N) {
        string s; cin >> s;
        State begin = s.begin();
        int ans = expression(begin);
        cout << ans << endl;
    }
    return 0;
}

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

typedef pair<int, int> Pair;

int _;
int n;
char buf[11451419];

Pair EvalElem(int pos);
Pair EvalTerm(int pos);
Pair EvalExp(int pos);

Pair EvalElem(int pos) {
  if (buf[pos] == '(') {
    Pair p = EvalExp(pos+1);
    return Pair(p.first, p.second+1);
  }

  char c = buf[pos];
  if ('0' <= c && c <= '9') {
    char *next;
    int res = strtol(buf+pos, &next, 10);
    return Pair(res, next-buf);
  }

  return Pair(-1, -1);
}

Pair EvalTerm(int pos) {
  Pair p = EvalElem(pos);
  assert(p.second != -1);

  pos = p.second;
  char c = buf[pos];
  if (c == '*') {
    Pair q = EvalTerm(pos+1);
    return Pair(p.first*q.first, q.second);
  }

  if (c == '/') {
    Pair q = EvalTerm(pos+1);
    return Pair(p.first/q.first, q.second);
  }

  return p;
}

Pair EvalExp(int pos) {
  Pair p = EvalTerm(pos);
  pos = p.second;

  char c = buf[pos];
  int res = p.first;
  if (c == '=' || c == ')') {
    return Pair(res, pos);
  }

  Pair q = EvalExp(pos+1);
  if (c == '+') res += q.first;
  else if (c == '-') res -= q.first;
  else assert(0);

  return Pair(res, q.second);
}

int main() {
  scanf("%d ", &_);
  while (_--) {
    scanf("%s", buf);
    n = strlen(buf);

    Pair res = EvalExp(0);
    assert(res.second == n-1);
    printf("%d\n", res.first);
  }
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)
typedef string::const_iterator State;

string s;

int eval(State &beg);

int number( State &beg ){
    if(*beg=='('){
        beg++;
        int ret = eval(beg);
        beg++;
        return ret;
    }
    
    string ret="";
    while(1){
        if( isdigit(*beg) ){
            ret+=*beg;
            beg++;
        }
        else break;
    }
    
    return stoi(ret);
}

int term(State &beg){
    int ret = number(beg);
    
    while(1){
        if( *beg=='*' ){
            beg++;
            ret *= number(beg);
        }
        else if( *beg=='/' ){
            beg++;
            ret /= number(beg);
        }
        else break;
    }

    return ret;
}

int eval(State &beg){
    int ret=term(beg);
    
    while(*beg!='=' && *beg!=')'){
        beg++;
        if(*(beg-1)=='+')       ret+=term(beg);
        else if(*(beg-1)=='-')  ret-=term(beg);
        else throw("error");
    }
    return ret;
}
int main(){
    int n;
    cin>>n;
    rep(i,n){
        cin>>s;
        
        State beg = s.begin();
        try{
            cout<<eval(beg)<<endl;
        }catch(string s){
            cout<<s<<endl;
        }
    }
}