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 <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;
  int res = p.first;
  while (1) {
    char c = buf[pos];
    if (c != '*' && c != '/') break;

    if (c == '*') {
      Pair q = EvalElem(pos+1);
      res *= q.first;
      pos = q.second;
    } else {
      Pair q = EvalElem(pos+1);
      res /= q.first;
      pos = q.second;
    }
  } 

  return Pair(res, pos);
}

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 <string>
#include <vector>
#include <iostream>
using namespace std;
string S; int n, junjo[4] = { 0, 0, 1, 1 };
long long calc(int L,int R){
    int K=0;
    vector<int>junjo2[4];
    for(int i=0;i<4;i++){
        junjo2[junjo[i]].push_back(i);
    }
    for(int i=0;i<4;i++){
        if(junjo2[i].size()>=1){
            for(int j=R-1;j>=L;j--){
                if(S[j]=='('){K++;}
                if(S[j]==')'){K--;}
                for(int k=0;k<junjo2[i].size();k++){
                    if(junjo2[i][k]==0){
                        if(S[j]=='+' && K==0){
                            return calc(L,j)+calc(j+1,R);
                        }
                    }
                    if(junjo2[i][k]==1){
                        if(S[j]=='-' && K==0){
                            return calc(L,j)-calc(j+1,R);
                        }
                    }
                    if(junjo2[i][k]==2){
                        if(S[j]=='*' && K==0){
                            return calc(L,j)*calc(j+1,R);
                        }
                    }
                    if(junjo2[i][k]==3){
                        if(S[j]=='/' && K==0){
                            return calc(L,j)/calc(j+1,R);
                        }
                    }
                }
            }
        }
    }
    if(S[L]=='(' && S[R-1]==')'){return calc(L+1,R-1);}
    return stoi(S.substr(L,R-L));
}
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) cin >> s, printf("%d\n", calc(0, s.size() - 1));
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef string::const_iterator State;
struct Parser
{
    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)
    {
        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;
    for(int i = 0; i < N; i++)
    {
        Parser ps;
        string s; cin >> s;
        State begin = s.begin();
        int ans = ps.expression(begin);
        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#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 REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;


class Source{
private:
    string str;
    int pos;
    
public:
    int peek(){
        if(pos<str.size())return str[pos];
        return -1;
    }
    
    void next(){
        pos++;
    }
    
    void init(string _str){
        str=_str;
        pos=0;
    }
    
};


class Parser{
private:
    Source src;
    
public:
    Parser(string str){
        src.init(str);
    }
    
    bool isDigit(char s){
        if(s>='0'&&s<='9')return true;
        return false;
    }
    
    int number(){
        string res;
        while(src.peek()!=-1&&isDigit(src.peek())){
            res+=src.peek();
            src.next();
        }
        return stoi(res);
    }
    
    int expr(){
        int x=term();
        while(true){
            switch(src.peek()) {
                case '+':
                    src.next();
                    x+=term();
                    continue;
                case '-':
                    src.next();
                    x-=term();
                    continue;
            }
            break;
        }
        return x;
    }
    
    int term(){
        int x=factor();
        while(true){
            switch(src.peek()){
                case '*':
                    src.next();
                    x*=factor();
                    continue;
                case '/':
                    src.next();
                    x/=factor();
                    continue;
            }
            break;
        }
        return x;
    }
    
    int factor(){
        if(src.peek()=='('){
            src.next();
            int res=expr();
            if(src.peek()==')'){
                src.next();
            }
            return res;
        }
        return number();
    }
    
};



int main(){
  
    int n;
    cin>>n;
    
    REP(i,n){
        string s;
        cin>>s;
        
        s=s.substr(0,s.size()-1);
        
        Parser par(s);
        cout<<par.expr()<<endl;
        
    }
    
    return 0;
}