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 <string>
#include <vector>
#include <algorithm>
#include <cctype>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef string::const_iterator State;
#define rep(i,n) for(int i=0;i<(n);i++)

class Parser{
public:
	int expression(State &begin){
		int ret = term(begin);
		for(;;){
			if(*begin == '+'){
				begin++;
				ret += term(begin);
			}else if(*begin == '-'){
				begin++;
				ret -= term(begin);
			}else{
				break;
			}
		}
		return ret;
	}
	int term(State &begin){
		int ret = factor(begin);
		for(;;){
			if(*begin == '*'){
				begin++;
				ret *= factor(begin);
			}else if(*begin == '/'){
				begin++;
				ret /= factor(begin);
			}else{
				break;
			}
		}
		return ret;
	}
	int factor(State &begin){
		int ret;
		if(*begin == '('){
			begin++;//'('?????????
			ret = expression(begin);
			begin++;//')'?????????
		}else{
			ret = number(begin);
		}
		return ret;
	}
	int number(State &begin){
		int ret = 0;
		while(isdigit(*begin)){
			ret *= 10;
			ret += *begin - '0';
			begin++;
		}
		return ret;
	}
};

int main(void){
	int n; cin >> n;
	rep(i, n){
		Parser ps;
		string s; cin >> s;
		string tmp = s.substr(0, s.size() - 1);
		// cout << tmp << endl;
		State begin = s.begin();
		int ret = ps.expression(begin);
		printf("%d\n", ret);
	}
	return 0;
}

C++:  #include<iostream>
 #include<string>
 
 using namespace std;
 
 int expression();
 int term();
 int factor();
 
 string exp;
 int p;
 
 int expression(){
     int value = term();
     if( exp[p] == '+' || exp[p] == '-' ){
         if ( exp[p] == '+' ) { p++; value += term(); }
         else { p++; value -= term(); }
     }
     return value;
 }
 
 int term(){
     int value = factor();
     if( exp[p] == '*' || exp[p] == '/' ){
         if ( exp[p] == '*' ) { p++; value *= factor(); }
         else { p++; value /= factor(); }
     }
     return value;
 }
 
 int factor(){
     int value = 0;
     if ( exp[p] == '(' ){
         p++; value = expression(); p++;
     } else {
         while( isdigit(exp[p]) ) { value = value*10 + exp[p++] - '0';}
     }
     return value;
 }
 
 int main(){
     int tcase; cin >> tcase;
     for ( int i = 0; i < tcase; i++ ){
         cin >> exp;
         p = 0;
         cout << expression() << endl;
     }
     return 0;
 }

C++: #include<iostream>
#include<string>
#include<sstream>
using namespace std;

string s;

int stoi(string str){
  stringstream ss(str);
  int n;
  ss >> n;
  return n;
}

int parse(int l, int r){
  int n = 0, i;
  for(int i=r-1;i>=l;i--){
    if(s[i] == ')')n++;
    if(s[i] == '(')n--;
    if(!n){
      if(s[i] == '+')return parse(l,i) + parse(i+1,r);
      if(s[i] == '-')return parse(l,i) - parse(i+1,r);
    }
  }
  for(int i=r-1;i>=l;i--){
    if(s[i] == ')')n++;
    if(s[i] == '(')n--;
    if(!n){
      if(s[i] == '*')return parse(l,i) * parse(i+1,r);
      if(s[i] == '/')return parse(l,i) / parse(i+1,r);
    }
  }

  if(s[l] == '(' && s[r-1] == ')')return parse(l+1,r-1);
  return stoi( s.substr(l,r-l) );
}

int main(){
  int n;
  cin >> n;
  while(n--){
    cin >> s;
    cout << parse(0,(int)s.size()-1) << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <time.h>
#include <cctype>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=1e+5+10;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=1e+9 + 7;

typedef string::const_iterator SC;

int factor(SC&);

// ??°????????????
int number(SC& begin){
  int res = 0;

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

  return res;
}

// ??????
int term(SC& begin){
  int res = factor(begin);

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

// ????????????
int expression(SC& begin){
  int res = term(begin);

  while(1){
    if(*begin == '+'){
      begin++;
      res += term(begin);
    }
    else if(*begin == '-'){
      begin++;
      res -= term(begin);
    }
    else{
      break;
    }
  }
  return res;
}

// ??¬??§?????°????????????
int factor(SC& begin){
  if (*begin == '('){
    begin++;
    int res = expression(begin);
    begin++;
    return res;
  }
  else{
    return number(begin);
  }
}

int main() {
	int n;
	cin >> n;
	string s;
	REP(i,n){
		cin >> s;
		SC begin = s.begin();
		cout << expression(begin) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <string>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;

string lltostr(ll n) {
  // cout << "lltostr " << n << endl;
  stringstream ss;
  ss << n;
  return ss.str();
}

ll calc(string str) {
  // ©Á±ª êÎêÔOÌ©Á±ðÍ¸·
  int p = 0, s = 0;
  // cout << "before " << str << endl;
  REP(i,str.length()) {
    if (str[i] == '(') {
      p++;
      s = i;
    }
    if (str[i] == ')') {
      if (p==1) {
        string tmp = lltostr(calc(str.substr(s+1,i-s-1)));
        str = str.substr(0,s) + tmp + str.substr(i+1);
        i = s + tmp.length()-1;
      }
      p--;
    }
  }
  p = -1;
  // cout << "remove () " << str << endl;
  REP(i,str.length()) {
    char c = str[i];
    if (c=='*' || c=='/') {
      string a = str.substr(p+1,i-p-1);
      int q = i;
      string b;
      for(i++;i<str.length();i++) {
        if (i!=q+1 && !isdigit(str[i])) {
          b = str.substr(q+1,i-q-1);
          break;
        }
      }
      if (i == str.length())
        b = str.substr(q+1);
      string tmp;
      if (c=='*')
        tmp = lltostr(atoll(a.c_str()) * atoll(b.c_str()));
      else if (c=='/')
        tmp = lltostr(atoll(a.c_str()) / atoll(b.c_str()));
      str = str.substr(0,p+1) + tmp + str.substr(i);
      i = p + tmp.length();
    }
    if (!isdigit(str[i])) {
      p = i;
    }
  }
  // cout << "cal *|/ " << str << endl;
  p = -1;
  REP(i,str.length()) {
    char c = str[i];
    if (c=='+' || c=='-') {
      string a = str.substr(p+1,i-p-1);
      int q = i;
      string b;
      for(i++;i<str.length();i++) {
        if (i!=q+1 && !isdigit(str[i])) {
          b = str.substr(q+1,i-q-1);
          break;
        }
      }
      if (i == str.length())
        b = str.substr(q+1);
      string tmp;
      if (c=='+')
        tmp = lltostr(atoll(a.c_str()) + atoll(b.c_str()));
      else if (c=='-')
        tmp = lltostr(atoll(a.c_str()) - atoll(b.c_str()));
      str = str.substr(0,p+1) + tmp + str.substr(i);
      i = p + tmp.length();
    }
    if (!isdigit(str[i])) {
      p = i;
    }
  }
  // cout << "cal +|- " << str << endl;
  return atoll(str.c_str());
}

int main() {
  int n;
  cin >> n;
  cin.ignore();
  while(n--) {
    string s;
    getline(cin,s);
    s = s.substr(0,s.length()-1);
    cout << calc(s) << endl;
  }
}