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<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int roc = 0;
string s;
int insu();
int kou();
int shiki();

int insu() {
	if(s[roc] >= '0' && s[roc] <= '9') {
		int j = roc;
		while(roc < s.size() && s[roc] >= '0' && s[roc] <= '9') ++roc;
		return stoi(s.substr(j, roc - j));
	} else {
		++roc;
		int res = shiki();
		++roc;
		return res;
	}
}

int kou() {
	int res = insu();
	while (s[roc] == '*' || s[roc] == '/') {
		if(s[roc] == '*') {
			++roc;
			res *= insu();
		}
		else {
			++roc;
			res /= insu();
		}
	}
	return res;
}

int shiki() {
	int res = kou();
	while (s[roc] == '+' || s[roc] == '-') {
		if(s[roc] == '+') {
			++roc;
			res += kou();
		}
		else {
			++roc;
			res -= kou();
		}
	}
	return res;
}

int main(void) {
	int n;
	cin>>n;
	REP(roop, n) {
		roc = 0;
		cin>>s;
		s.pop_back();
		cout<<shiki()<<endl;
	}
}

C++: #include <iostream>
#include <cassert>
#include <cctype>
using namespace std;

string S;
size_t cur;

int digit() {
  assert(isdigit(S[cur]));
  int n = S[cur] - '0'; // ASCII code -> digit
  cur = cur+1;
  return n;
}

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

int expression();

int factor() {
  if (S[cur] != '(') return number();
  cur += 1;
  int n = expression();
  assert(S[cur] == ')');
  cur += 1;
  return n;
}

int term() {
  int a = factor();
  while (cur<S.size() && (S[cur]=='*' || S[cur]=='/')) {
    char op = S[cur++];
    int b = factor();
    if (op=='*') a *= b;
    else a /= b;
  }
  return a;
}

int expression() {
  int a = term();
  while (cur<S.size() && (S[cur]=='+' || S[cur]=='-')) {
    char op = S[cur++];
    int b = term();
    if (op == '+') a += b;
    else a -= b;
  }
  return a;
}

#if 0
int parse() {return expression();}

int main() {
  int a = parse();
  cout << a << endl;
  assert(a == 4);
  assert(cur == S.size());
  return 0;
}
#endif
  
int main() {
  int N;
  cin >> N;
  for (int i=0; i<N; i++){
    cur = 0;
    cin >> S;
    S.resize(S.size()-1); // delete '='
    cout << expression() << endl;
  }
  return 0;
}

C++: //
//AOJ vol1 109
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0109&lang=jp
//2017/07/10
//640009E
//Yang Bo
//

#include <iostream>
#include <cctype>

using namespace std;

string S;
size_t cur = 0;

//string?????°??????int???"??°???"???????????????
int digit()
{
  int n = S[cur] - '0';
  cur++; //cur?????????????????????????????????(?¬??????°??????)
  //cout << "cur_digit = " << cur << endl;
  return n;
}

//?????????????????????????????????????????????????????????
int number()
{
  int n = digit();
  while (cur < S.size() && isdigit(S[cur])) //?????¨?????¨???????????°
    n = n * 10 + digit();
  //cout << "cur_number = " << cur << endl;
  return n;
}

int expression(); //??£?¨?

//??¬??§????????§?????????
int brackets()
{
  //??¬??§???????????´???
  if (S[cur] != '(')
    return number();
  //??¬??§???????????´???
  cur++;
  int n = expression();
  cur++; //')'??????????????????????????????
  //cout << "cur_brackets = " << cur << endl;
  //cout << "n = " << n << endl;
  return n;
}

//????????????????????????
int term()
{
  int a = brackets(); //????????????????????°
  while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')) {
    char op = S[cur++];
    int b = brackets(); //???????????????????????°(?¶????????????°?????????)
    if (op == '*')
      a *= b;
    else if (op == '/')
      a /= b;
  }
  //cout << "cur_term = " << cur << endl;
  //cout << "a_term = " << a << endl;
  return a;
}

//????????????????????????
int expression()
{
  int a = term(); //????????????????????°
  while (cur < S.size() && (S[cur] == '+' || S[cur] == '-')) {
    char op = S[cur++]; //cur?????????????????????????????????(?????????????????????)
    int b = term(); //???????????????????????°(?¶????????????°?????????)
    if (op == '+')
      a += b;
    else if (op == '-')
      a -= b;
  }
  //cout << "cur_expression = " << cur << endl;
  //cout << "a_expression = " << a << endl;
  return a;
}

int main()
{
  int n; cin >> n;
  while (n-- > 0) {
    cur = 0;
    cin >> S;
    int a = expression();
    cout << a << endl;
  }
}

/*
  ?????£??¨?????????????????´??\??\??????????????????????????????????????¨????????????????????§????????????????????????????????£????????§?????????
  ?????????????????????????§????????????§????????±????????????????????????????§£???????????????
  11.A??????????????????????????§????????????????§£?????????????????????????????£???????????£??????????????????????????????
  ???????????????????????????????????°???2??\????????????cur?????°?????????????????°?????¨?°???\???????????????cur???0??????????????????????????°?????????????????¨????°???\?????????????????????????????£??????
  ????????¨?????\????????????????????£???Encryption System?????¢??????????????£????????§????????????????????¨???????§£??????????????????
*/