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 long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


typedef string::const_iterator State;
ll siso(State &begin);
ll jou(State &begin);
ll kak(State &begin);
ll num(State &begin);

ll num(State &begin){
    ll ret=0;
    while(isdigit(*begin)){
        ret*=10;
        ret+=*begin-'0';
        begin++;
    }
    return ret;
}
ll kak(State &begin){
    if(*begin=='('){
        begin++;
        ll ret=siso(begin);
        begin++;
        return ret;
    }else{
        return num(begin);
    }
}
ll jou(State &begin){
    ll ret=kak(begin);
    while(1){
        if(*begin=='*'){
            begin++;
            ret*=kak(begin);
        }else if(*begin=='/'){
            begin++;
            ret/=kak(begin);
        }else{
            break;
        }
    }
    return ret;
}
ll siso(State &begin){
    ll ret=jou(begin);
    while(1){
        if(*begin=='+'){
            begin++;
            ret+=jou(begin);
        }else if(*begin=='-'){
            begin++;
            ret-=jou(begin);
        }else{
            break;
        }
    }
    return ret;
}

int main(){fastio
    //freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    
    ll n;cin>>n;cin.ignore();
    while(n--){
        string s;
        getline(cin,s);
        State b=s.begin();
        cout<<siso(b)<<endl;
    }
    
    return 0;
}

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

map<char,int> order;
string S; size_t cur=0;
stack<int> num,rnum;
stack<char> op,rop;

int digit(){
	int n=S[cur++]-'0';
	return n;
}

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

void calc(){
	int b=num.top();num.pop();
	int a=num.top();num.pop();
	char o=op.top();op.pop();
	int c;
	switch(o){
		case '+' :
			c=a+b;
			break;
		case '-' :
			c=a-b;
			break;
		case '*' :
			c=a*b;
			break;
		case '/' :
			c=a/b;
			break;
		default :
			break;
	}
	num.push(c);
	return ;
}

void calc2(){
	int a=rnum.top();rnum.pop();
	int b=rnum.top();rnum.pop();
	char o=rop.top();rop.pop();
	int c;
	switch(o){
		case '+' :
			c=a+b;
			break;
		case '-' :
			c=a-b;
			break;
		case '*' :
			c=a*b;
			break;
		case '/' :
			c=a/b;
			break;
		default :
			break;
	}
	rnum.push(c);
	return ;
}

int exp(){
	cur =0;
	int smax=S.size();
	while(cur < smax-1){
		//cout << cur << endl;
		if(isdigit(S[cur])){
			int a=number();
			num.push(a);
	//	}else if(!op.empty()&&op.top()!='('&&op.top()!=')'&& order[S[cur]] > order[op.top()]){ //計算順序については改善の余地あり (　は最小に
	//		calc();
	//		op.push(S[cur++]);
		}else if(S[cur] == ')' ){
			if(!op.empty()&&op.top()!='(')
				calc();
			rnum.push(num.top());num.pop();
 			while(!op.empty()&&op.top()!='('){
				rop.push(op.top());op.pop();
				rnum.push(num.top());num.pop();
			}
			while(!rop.empty())
				calc2();
			num.push(rnum.top());rnum.pop();
			//cout << num.top() << endl;
			op.pop();cur++;
		}else{//ひとまず終了　演算記号のチェックも入れる
			//	cout << "come" << endl;
			op.push(S[cur++]);
		}
	}

	if(op.size()>=2){
		char op1,op2;
		op1=op.top();op.pop();op2=op.top();
		op.push(op1);
		if(order[op1]<order[op2])
			calc();
	}
	//cout << num.top() << endl;//
	//int tmp1=num.top();num.pop();
	//cout << num.top() << endl;//
	//int tmp2=num.top();num.pop();
	//cout << num.top() << endl;//
	//num.push(tmp2);
	//num.push(tmp1);

	rnum.push(num.top());num.pop();
	while(!op.empty()&&op.top()!='('){
		rop.push(op.top());op.pop();
		rnum.push(num.top());num.pop();
	}
	while(!rop.empty())
		calc2();
	num.push(rnum.top());rnum.pop();
	//cout<< " check "  << op.empty() << endl;
	int ans=num.top();
	num.pop();
	return ans;
}

int main(void){
	order['+']=2;
	order['-']=2;
	order['*']=1;
	order['/']=1;
	//cout << order['('] << endl;
	int n;
	cin >> n;
	while(n--){
		cin >> S;
		cout << exp() << endl;
	}
	return 0;
}

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

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

bool is_digit(char c){
  return '0' <= c && c <= '9';
}
string i2s(int i) {
  stringstream ss;
  ss << i;
  return ss.str();
}

string parse(int i, string s) {
  //cout<<s<<endl;
  bool flag = true;
  
  // brace
  if (s.find('(') != -1) {
    // æª©ç`FbNµÄA')'Éoï¤êÆ
    // »¤ÅÈ¢êÉª¯é
    bool mode = true;
    REP(j,s.find('(')+1, s.size()) {
      if (s[j] == ')') break;
      if (s[j] == '(') {
        mode = false;
        break;
      }
    }
    // ÊÌÊuðæ¾·é
    int lbr = s.find('('), rbr;
    if (mode) {
      rbr = s.find(')');
    } else {
      for(int j=s.size()-1;j>=0;j--) if (s[j] == ')') {
        rbr = j; break;
      }
    }
    // ÊàÌvZðæÉs¤½ßÉssð¾é
    string inner = parse(0, s.substr(lbr+1, rbr-lbr-1));
    // ÊàðÁ·é
    s.erase(lbr, rbr-lbr+1);
    s.insert(lbr, inner);
    //cout<<"brace:"<<s<<endl;
    return parse(0, s);
  }
  
  rep(i,s.size()) if (s[i] == '*' || s[i] == '/') {
    int lhs, rhs, res;
    int li = i-1, ri = i+1;
    if (ri + 1 < s.size() && s[ri] == '-') ri++;

    while (is_digit(s[li]) || s[li] == '-' && li >= 0) li--;
    while (is_digit(s[ri]) && ri < s.size()) ri++;
    lhs = atoi(s.substr(li+1, i-1-li).c_str());
    rhs = atoi(s.substr(i+1, ri-1-i).c_str());
    //cout<<s.substr(li+1, i-1-li)<<"|"<<s.substr(i+1, ri-1-i)<<endl;

    if (lhs == 0 || rhs == 0) {
      res = 0;
    } else {
      if (s[i] == '*') {
        res = lhs * rhs;
      } else {
        res = lhs / rhs;
      }
    }
    
    s.erase(li+1, ri-li-1);
    s.insert(li+1, i2s(res));
    return parse(0, s);
  }
  
  rep(i,s.size()) if (s[i] == '+' || s[i] == '-') {
    if (s[i] == '-' && i == 0) continue; 
    int lhs, rhs, res;
    int li = i-1, ri = i+1;
    if (ri + 1 < s.size() && s[ri] == '-') ri++;
    
    while (is_digit(s[li]) || s[li] == '-' && li >= 0) li--;
    while (is_digit(s[ri]) && ri < s.size()) ri++;
    lhs = atoi(s.substr(li+1, i-1-li).c_str());
    rhs = atoi(s.substr(i+1, ri-1-i).c_str());
    //cout<<"dbg::"<<li<<"|"<<ri<<endl;
    //cout<<s.substr(li+1, i-1-li)<<"|"<<s.substr(i+1, ri-1-i)<<endl;
    if (s[i] == '+') {
      res = lhs + rhs;
    } else {
      res = lhs - rhs;
    }
    s.erase(li+1, ri-li-1);
    s.insert(li+1, i2s(res));
    //cout<<s<<endl;
    return parse(0, s);
  }
  
  return s;
}

void solve() {
  string s; cin>>s;
  s = s.substr(0, s.size()-1);
  cout<<parse(0, s)<<endl;
}

int main (int argc, char const* argv[]) {
  int n; cin>>n;
  rep(i,n) solve();
  return 0;
}