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;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

using State = string::const_iterator;
class ParseError {};

//-------------------------------------

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

int main() {
    int t;
    cin >> t;
    while(t--) {
        string s;
        cin >> s;
        State now = s.begin();
        int ans = expr(now);
        cout << ans << endl;
    }
}

int number(State &now) {
    int res = 0;
    while(isdigit(*now)) {
        res *= 10;
        res += *now - '0';
        now++;
    }
    return res;
}

int term(State &now) {
    int res = factor(now);
    while(1) {
        if(*now == '*') {
            now++;
            res *= factor(now);
        } else if(*now == '/') {
            now++;
            res /= factor(now);
        } else {
            break;
        }
    }
    return res;
}

int expr(State &now) {
    int res = term(now);
    while(1) {
        if(*now == '+') {
            now++;
            res += term(now);
        } else if(*now == '-') {
            now++;
            res -= term(now);
        } else {
            break;
        }
    }
    return res;
}

int factor(State &now) {
    if(*now == '(') {
        now++;
        int res = expr(now);
        now++;
        return res;
    } else {
        return number(now);
    }
}

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

inline bool is_op(string &in) {
	if (in.size() == 1 && !isdigit(in[0]))
	{
		return true;
	}
	else
	{
		return false;
	}
}
inline bool is_num(string &in)
{
	for (auto i : in)
	{
		if (!isdigit(i))
			return false;
	}
	return true;
}
inline bool is_expr(string &in)
{
	if (!is_num(in) && !is_op(in)) { return true; }
	else { return false; }
}
vector<string> split(string in)
{
	vector<string> spl;
	int pos = 0;
	if (in[pos] == '-') 
	{
		pos++;
		while (pos < in.size()) {
			if (isdigit(in[pos])) {
				pos++;
			}
			else {
				break;
			}
		}
		spl.push_back(in.substr(0, pos));
		in.erase(0, pos);
		pos = 0;
	}
	while ( pos < in.size())
	{
		if (!isdigit(in[pos]))
		{
			if (pos != 0)
			{
				spl.push_back(in.substr(0, pos));
				in.erase(0, pos);
				pos = 0;
			}
			else
			{
				if (in[0] == '(')
				{
					int cnt = 1;
					int r_pos = 1;
					for (r_pos = 1; r_pos < in.size(); r_pos++)
					{
						if (in[r_pos] == '(')
							cnt++;
						if (in[r_pos] == ')')
							cnt--;
						if (cnt == 0)
							break;
					}
					spl.push_back(in.substr(pos + 1, r_pos - 0 - 1));
					in.erase(0, r_pos + 1);
					pos = 0;
					continue;
				}
				else if (in[0] == '+' || in[0] == '-' || in[0] == '*' || in[0] == '/')
				{
					spl.push_back(in.substr(0, 1));
					in.erase(0, 1);
					pos = 0;
				}
			}
		}
		else {
			pos++;
		}
	}
	if (in.size() != 0) spl.push_back(in);
	return spl;
}
int cal(string &in_str) {
	auto in = split(in_str);
	while (in.size() != 1) {
		auto pos = in.begin();
		while (pos != in.end()) 
		{
			if (*pos == "*") {
				pos--;
				*pos = to_string(cal(*pos)*cal(*(pos + 2)));
				in.erase(pos+1 , pos + 3);
			}
			else if (*pos == "/") {
				pos--;
				*pos = to_string(cal(*pos)/cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			if (in.size()==1) break;
			if (pos != in.end()) pos++;
		}
		pos = in.begin();
		while (pos != in.end()) {
			if (*pos == "+") {
				pos--;
				*pos = to_string(cal(*pos)+cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			else if (*pos == "-") {
				pos--;
				*pos = to_string(cal(*pos) - cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			if (in.size()==1) break;
			if(pos != in.end()) pos++;
		}
	}
	return(stoi(in[0]));
}
int main()
{
	/*string tmp = "(-2*2)*5+(1+2)*(3+4)";
	auto out=split(tmp);
	for (auto i : out) {
		cout << i << endl;
	}
	cout << cal(tmp) << endl;*/
	string input;
	int n;
	cin >> n;
	while (n--) {
		cin >> input;
		input.erase(input.end() - 1);
		cout << cal(input) << endl;
	}
	return 0;
}

C++: 
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <cctype>
using namespace std;

typedef string::const_iterator State;
int expression(State &begin);

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


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

int main() {
	int N;
	cin >> N;
	cin.ignore();
	for (int i = 0; i < N; i++) {
		string str;
		getline(cin, str);
State s = str.begin();
		cout << expression(s) << endl;
	}
	return 0;
}

C++: //suhan lee,saitama university

#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <complex>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repn(i,n) for(int i=0;i<n;i++)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
#define pb push_back 
#define pf push_front
ll ex1(string input,ll& i);
ll ex2(string input,ll& i);
ll ex3(string input,ll& i);
ll exnum(string input,ll& i);
ll ex1(string input,ll& i){
  ll a=0;;
  a=+ex2(input,i);
  while(true){
    if(input[i]=='+')
      a= a+ex2(input,++i);
    else if(input[i]=='-')
      a=a-ex2(input,++i);
    else return a;
  }
}

ll ex2(string input,ll& i){
  ll a=ex3(input,i);
  while(true){
    if(input[i]=='*')
      a*=ex3(input,++i);
    else if(input[i]=='/')
      a/=ex3(input,++i);
    else return a;
  }
}
ll ex3(string input,ll& i){
  ll a;
  if(input[i]=='('){
    a=ex1(input,++i);
    i++;
  }
  else a=exnum(input,i);
  return a;
}
ll exnum(string input,ll &i){
  ll a=0;
  while(isdigit(input[i])){
    //  cout<<"i:"<<i<<endl;
    a*=10;
    a+=input[i]-'0';
    i++;
  }
  //  cout<<"a:"<<a<<endl;
  return a;
}

int main(){
  ll n;
  cin>>n;
  repn(k,n){
    ll i=0;
    string input;
    cin>>input;
    cout<<ex1(input,i)<<endl;
  }
  return 0;
}