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>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

template<class T>
struct Parse{
    typedef string::const_iterator itr;
    itr begin;
    T ans;
    Parse(const string &s){
        begin=s.begin();
        ans=expr(begin);
        cerr<<s<<" "<<ans<<"\n";
    }
    T expr(itr &begin){
        T ret=term(begin);
        while(1){
            if((*begin)=='+'){
                consume(begin,'+');
                ret+=term(begin);
            }else if((*begin)=='-'){
                consume(begin,'-');
                ret-=term(begin);
            }else{
                return ret;
            }
        }
    }
    T numb(itr &begin){
        T ret=0;
        while('0'<=(*begin)&&(*begin)<='9'){
            ret*=10;
            ret+=(*begin)-'0';
            begin++;
        }
        return ret;
    }
    T fact(itr &begin){
        T ret=0;
        if((*begin)=='('){
            consume(begin,'(');
            ret=expr(begin);
            consume(begin,')');
        }else{
            ret=numb(begin);
        }
        return ret;
    }
    T term(itr &begin){
        T ret=fact(begin);
        while(1){
            if((*begin)=='*'){
                consume(begin,'*');
                ret*=fact(begin);
            }else if((*begin)=='/'){
                consume(begin,'/');
                ret/=fact(begin);
            }else{
                return ret;
            }
        }
    }
    void consume(itr &begin,char expected){
        if(*begin==expected){
            begin++;
        }else{
            fprintf(stderr,"Expected: '%c' Got: '%c'\n",expected,*begin);
            fprintf(stderr,"Rest string is ");
            while(*begin){
                fprintf(stderr,"%c",*begin++);
            }
            return;
        }
    }
};

int main(){
    int n; cin>>n;
    while(n--){
        string s; cin>>s;
        Parse<int> parse(s);
        cout<<parse.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;
  if (buf[pos] == '*') {
    Pair q = EvalExp(pos+1);
    return Pair(p.first*q.first, q.second);
  }

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

  return p;
}

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

  Pair q = EvalExp(pos+1);
  if (buf[pos] == '+') res += q.first;
  else if (buf[pos] == '-') 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 <iostream>
#include <stack>
#include <map>
#include <string>
#include <cctype>
using namespace std;

map<char,int> order;
string S; size_t cur=0;
stack<int> num,rnum,tmpnum;
stack<char> op,rop,tmpop;

int digit(){
	int n=S[cur++]-'0';
	return n;
}

int number(){
	int n=digit();
	while(isdigit(S[cur]))
		n=n*10+digit();
	return n;
}

void calc(){
	for(int i=1;i<=2;i++){
		while(!rop.empty()){
			if(order[rop.top()]!=i){
				tmpop.push(rop.top());rop.pop();
				tmpnum.push(rnum.top());rnum.pop();
			}
			else{
				int a=rnum.top();rnum.pop();
				int b=rnum.top();rnum.pop();
				char o=rop.top();rop.pop();
				int c;
				switch(o){
					case '+' :
						c=a+b;
						break;
					case '-' :
						c=a-b;
						break;
					case '*' :
						c=a*b;
						break;
					case '/' :
						c=a/b;
						break;
					default :
						break;
				}
				rnum.push(c);
			}
		}
		tmpnum.push(rnum.top());rnum.pop();
		if(tmpnum.size()==1)
			break;
		while(!tmpop.empty()){
			rop.push(tmpop.top());tmpop.pop();
			rnum.push(tmpnum.top());tmpnum.pop();
		}
		rnum.push(tmpnum.top());tmpnum.pop();
	}
	num.push(tmpnum.top());tmpnum.pop();
	return ;
}

int exp(){
	cur =0;
	int smax=S.size();
	while(cur < smax-1){
		//cout << cur << endl;
		if(isdigit(S[cur])){
			int a=number();
			num.push(a);
		}else if(S[cur] == ')' ){
 			while(!op.empty()&&op.top()!='('){
				rop.push(op.top());op.pop();
				rnum.push(num.top());num.pop();
			}
			rnum.push(num.top());num.pop();
			calc();
			//cout << num.top() << endl;
			op.pop();cur++;
		}else{//ひとまず終了　演算記号のチェックも入れる
			//	cout << "come" << endl;
			op.push(S[cur++]);
		}
	}
	//cout << num.top() << endl;//
	//int tmp1=num.top();num.pop();
	//cout << num.top() << endl;//
	//int tmp2=num.top();num.pop();
	//cout << num.top() << endl;//
	//num.push(tmp2);
	//num.push(tmp1);

	while(!op.empty()&&op.top()!='('){
		rop.push(op.top());op.pop();
		rnum.push(num.top());num.pop();
	}
	rnum.push(num.top());num.pop();

	calc();
	//cout<< " check "  << op.empty() << endl;
	int ans=num.top();
	num.pop();
	return ans;
}

int main(void){
	order['+']=2;
	order['-']=2;
	order['*']=1;
	order['/']=1;
	//cout << order['('] << endl;
	int n;
	cin >> n;
	while(n--){
		cin >> S;
		cout << exp() << endl;
	}
	return 0;
}