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 <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007


string s;



int calc(int b,int e){
	vector<int> v;
	vector<char> ope;
	for(int i=b; i<=e; i++){
		if(s[i]=='('){
			int o=1,c=0;
			for(int j=i+1; j<=e; j++){
				if(s[j]=='(')o++;
				if(s[j]==')'){
					c++;
					if(o==c){
						int a=calc(i+1,j+1);
						v.pb(a);
						i=j;
						break;
					}
				}
			}
		}
		else if(s[i]>='0'&&s[i]<='9'){
			for(int j=i+1; j<=e; j++){
				if(s[j]<'0'||s[j]>'9'){
					string t=s.substr(i,j);
					v.pb(atoi(t.c_str()));
					i=j-1;
					break;
				}
			}
		}
		else{
			ope.pb(s[i]);
		}
	}
	for(int i=0; i<ope.size(); i++){
		if(ope[i]=='*'){
			v[i+1]=v[i]*v[i+1];
			v[i]=0;
			ope[i]=(i==0?'+':ope[i-1]);
		}
		if(ope[i]=='*'){
			v[i+1]=v[i]/v[i+1];
			v[i]=0;
			ope[i]=(i==0?'+':ope[i-1]);
		}
	}
	for(int i=0; i<ope.size()-1; i++){
		if(ope[i]=='+'){
			v[0]+=v[i+1];
		}
		if(ope[i]=='-'){
			v[0]-=v[i+1];
		}
	}
	return v[0];
}


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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
string s;
int a;
int func();
int num();
int func2();
int num(){
	int out=0;
	while(isdigit(s[a])){out*=10;out+=s[a]-'0';a++;}
	return out;
}
int func2(){
	int out;
	if(isdigit(s[a]))out=num();
	else {a++;out=func();}
	while(a!=s.size()){
		if(s[a]=='*'){
			a++;
			if(s[a]=='('){a++;out*=func();}
			else out*=num();
		}else if(s[a]=='/'){
			a++;
			if(s[a]=='('){a++;out/=func();}
			else out/=num();
		}else return out;
	}
	return out;
}
int func(){
	int out;
	if(isdigit(s[a]))out=num();
	else {a++;out=func();}
	while(a!=s.size()){
		//cout<<a<<" "<<out<<endl;
		if(s[a]=='=')return out;
		if(s[a]==')'){a++;return out;}
		if(s[a]=='+'){a++;out+=func2();}
		else if(s[a]=='-'){a++;out-=func2();}
	}
	return out;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		a=0;
		cin>>s;
		s="0+"+s;
		cout<<func()<<endl;
	}
}