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"

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

string toRPN(string s){
    stack<char> ope;
    string ret;
    int len=s.size();
    
    for(int i=0;i<len;i++){
        if( isdigit(s[i]) ) ret+=s[i];
        
        else{
            if(s[i]=='('){
                ope.push(s[i]);
                
            }else if(s[i]==')'){
                while(ope.top()!='('){
                    ret+=ope.top();
                    ope.pop();
                }
                ope.pop();
                
            }else if( s[i]=='*' || s[i]=='/' ){
                while( !ope.empty() && (ope.top()=='*' || ope.top()=='/') ){
                    ret+=ope.top();
                    ope.pop();
                }
                ope.push(s[i]);
                
            }else if( s[i]=='+' || s[i]=='-' ){
                while( !ope.empty() && (ope.top()=='*' || ope.top()=='/' || ope.top()=='+' || ope.top()=='-') ){
                    ret+=ope.top();
                    ope.pop();
                }
                ope.push(s[i]);
                
            }else{
                return "invalid";
            }
        }
    }
    while(ope.size()){
        ret+=ope.top();
        ope.pop();
    }

    return ret;
}


string solveRPN(string s){
    stack<int> stk;

    
    for(int i=0;i<s.size();i++){
        if( isdigit(s[i]) )stk.push( s[i]-'0'  );
        else{
            int b=stk.top(); stk.pop();
            int a=stk.top(); stk.pop();
            
            if(s[i]=='+')stk.push(a+b);
            if(s[i]=='-')stk.push(a-b);
            if(s[i]=='*')stk.push(a*b);
            if(s[i]=='/')stk.push(a/b);
        }
    }
    
    stringstream ret;
    ret<<stk.top();
    
    return ret.str();
}


int main(){
    int n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        
        s.erase(s.size()-1);
        
        s=toRPN(s);
        s=solveRPN(s);
    
        cout<<s<<endl;
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
using namespace std;

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

int factor(State &begin);

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

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

int term(State &begin){
    int ret=factor(begin);

    while(true){
        if(*begin=='*')ret*=factor(++begin);
        else if(*begin=='/')ret/=factor(++begin);
        else break;
    }
    return ret;
}

int expression(State &begin){
    int ret=term(begin);
    while(true){
        if(*begin=='+')ret+=term(++begin);
        else if(*begin=='-')ret-=term(++begin);
        else break;
    }
    return ret;
}

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

int main(){

    int N;
    cin>>N;
    cin.ignore();
    string s[N];
    REP(i,N)getline(cin,s[i]);
    REP(i,N){
        State begin=s[i].begin();
        cout<<expression(begin)<<endl;
    }

    return 0;
}

C++: #include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string s;
int sp;

int expr(void);

int nextin(void){
  int res = 0;
  for(;;sp++){
    if('0' > s[sp] || s[sp] > '9')break;
    res *= 10;
    res += (int)(s[sp] - '0');
  }
  return res;
}
int nextint(void){
  if(s[sp] == '-'){
    sp++;
    return -1 * nextin();
  }
  return nextin();
}

int term(void){
  int res = 0;
  if(s[sp] == '('){
    ++sp; res += expr(); ++sp;
  }else res += nextint();
  return res;
}

int factor(void){
  int res = term();
  for(;;){
    if(s[sp] == '*'){
      ++sp; res *= term();
    }else if(s[sp] == '/'){
      ++sp; res /= term();
    }else break;
  }
  return res;
}

int expr(void){
  int res = factor();
  for(;;){
    if(s[sp] == '+'){
      ++sp; res += factor();
    }else if(s[sp] == '-'){
      ++sp; res -= factor();
    }else break;
  }
  return res;
}

int solve(void){
  sp = 0;
  int res = expr();
  return res;
}

signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase < 1234567;testcase++){
    int(n);
    for(;n--;){
      sc(s);
      pri(solve());
      s.clear();
    }

/*/

//*/ break;
  }
  return 0;
}