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 <vector>

using namespace std;

int eval(const string & expr) {
	int left = 0;
	int right = 0;
	int mdtemp = 0;
	int ev_idx = 0;
	int sign = 1; // 1=+, -1=-
	char c, cc;

	// 項の処理
	while((c = expr[ev_idx++]) != '=' && c != '\0') {
		if(c == '+' || c == '-') {
			left += sign * right;
			right = 0;
			if(c == '+') sign = 1;
			else sign = -1;
		} else if(c == '*' || c == '/') { // if mul,div
			mdtemp = 0;
			while(1) {
				if((cc = expr[ev_idx++]) == '=' || cc == '\0' || cc == '+' || cc == '-' || cc == '*' || cc == '/') {
					ev_idx--;
					break;
				}
				if(cc == '(') {
					int clen = 0;
					int cstrt = ev_idx;
					while(expr[ev_idx++] != ')') clen++;
					string ceval = expr.substr(cstrt, clen);
					mdtemp = eval(ceval);
				} else {
					mdtemp *= 10;
					mdtemp += (int)(cc - '0');
				}
			}
			if(c == '*') right *= mdtemp;
			else right /= mdtemp;
		} else if(c == '(') {
			int clen = 0;
			int cstrt = ev_idx;
			while(expr[ev_idx++] != ')') clen++;
			string ceval = expr.substr(cstrt, clen);
			right = eval(ceval);
		} else { // if numbers
			right *= 10;
			right += (int)(c - '0');
		}
	}
	left += sign * right;
	
	return left;
}

int main() {
	int n;
	cin >> n;
	
	vector<int> anss(n);

	for(int i=0;i<n;i++) {
		string expr;
		cin >> expr;
		int ans;
		ans = eval(expr);
		anss[i] = ans;
	}
	for(auto it = anss.begin(); it != anss.end(); it++) {
		cout << *it << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cctype>

using namespace std;

int number(const string &s, int &k);
int fact(const string &s, int &k);
int term(const string &s, int &k);

int expr(const string &s, int &k){
  int result = term(s,k);
  while(true){
    if(s[k]=='+')result += term(s,++k);
    else if(s[k]=='-')result -= term(s,++k);
    else break;
  }
  return result;
}

int term(const string &s, int &k){
  int res = fact(s,k);
  while(true){
    if(s[k]=='*')res *= fact(s,++k);
    else if(s[k]=='/')res /= fact(s,++k);
    else break;
  }
  return res;
}

int fact(const string &s, int &k){
  if(s[k]=='('){
    int res = 0;
    ++k;
    res = expr(s,k);
    k++;
    return res;
  }
  return number(s,k);
}

int number(const string &s, int &k){
  int res = 0;
  while(isdigit(s[k])){
    res *= 10;
    res += (int)(s[k++] - '0');
  }
  return res;
}

int main(void){

  int n;
  cin >> n;

  while(n--){
    string s;
    cin >> s;
    int k = 0;
    cout << expr(s, k) << endl;
  }
  
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long
int expression(string,int&);
int term(string,int&);
int factor(string,int&);
int number(string,int&);

bool f;

int expression(string s,int& p){
  int res=term(s,p);
  while(p<(int)s.size()){
    if(s[p]=='+'){
      p++;
      res+=term(s,p);
      continue;
    }
    if(s[p]=='-'){
      p++;
      res-=term(s,p);
      continue;
    }
    break;
  }
  return res;
}

int term(string s,int& p){
  int res=factor(s,p);
  while(p<(int)s.size()){
    if(s[p]=='*'){
      p++;
      res*=factor(s,p);
      continue;
    }
    if(s[p]=='/'){
      p++;
      int tmp=factor(s,p);
      if(tmp==0){
	f=1;
	break;
      }
      res/=tmp;
      continue;
    }
    break;
  }
  return res;
}

int factor(string s,int& p){
  int res;
  if(s[p]=='('){
    p++;
    res=expression(s,p);
    p++;
  }else{
    res=number(s,p);
  }
  return res;
}

int number(string s,int& p){
  int res=0;
  while(p<(int)s.size()&&isdigit(s[p]))
    res=res*10+s[p++]-'0';
  return res;
}

signed main(){
  string s;
  int p=0;
  cin>>s;
  cout<<expression(s,p)<<endl;
  return 0;
}

/*
verified on 2017/04/26
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?lang=jp&id=0109
*/

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);
#define readV(_v) rep(j, _v.size()) cin >> _v[j];
#define readVV(_vv) rep(i, _vv.size()) readV(_vv[i]);
#define output(_x) cout << _x << endl;

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

int number(State&);
int factor(State&);
int term(State&);
int expression(State&);

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);

    for (;;) {
        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);

    for (;;) {
        if (*begin == '+') {
            begin++;
            ret += term(begin);
        } else if (*begin == '-') {
            begin++;
            ret -= term(begin);
        } else {
            break;
        }
    }

    return ret;
}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    cin >> n;
    rep(i, n) {
        string s;
        cin >> s;

        State begin = s.begin();
        int ans = expression(begin);
        cout << ans << endl;
    }
}