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++: #define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#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 range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << endl
#else
const bool test = false;
#define dump(x) 
#endif

#else
const bool test = false;
#define dump(x) 
#endif

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep))
    {
        v.push_back(buffer);
    }
    return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
    return accumulate(begin, end, 0ll);
}

void solve();

signed main()
{
    cout << fixed << setprecision(20);
    solve();
    return 0;
}

// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'

int number(const string& s, int& i);
int factor(const string& s, int& i);
int term(const string& s, int& i);
int expr(const string& s, int& i);

int number(const string& s, int& i) {
    int res = 0;
    bool minus_flag = false;
    if (s[i] == '-') {
        minus_flag = true;
        i++;
    }
    for (; isdigit(s[i]); i++) {
        res *= 10;
        res += s[i] - '0';
    }
    if (minus_flag) res *= -1;
    return res;
}

int factor(const string& s, int& i) {
    if (isdigit(s[i]) || s[i] == '-') return number(s, i);
    i++;
    int res = expr(s, i);
    i++;
    return res;
}

int term(const string& s, int& i) {
    int res = factor(s, i);
    while (s[i] == '*' || s[i] == '/') {
        char op = s[i];
        i++;
        int a = factor(s, i);
        if (op == '*') res *= a;
        else           res /= a;
    }
    return res;
}

int expr(const string& s, int& i) {
    int res = term(s, i);
    while (s[i] == '+' || s[i] == '-') {
        char op = s[i];
        i++;
        int a = term(s, i);
        if (op == '+') res += a;
        else           res -= a;
    }
    return res;
}

int eval(const string& s) {
    int i = 0;
    return expr(s, i);
}

void solve() {
    int N;
    string s;
    cin >> N;
    rep(i, N) {
        cin >> s;
        cout << eval(s) << endl;
    }
}

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

int hyoka(string);
int isNum(int);

int main(){
	int n,i;
	string s;
	
	cin>>n;
	for(i=0;i<n;i++){
	 cin>>s;
	 cout<<hyoka(s)<<endl;
	}
		
	return 0;
}


int hyoka(string s){
	long int total=0,work=0;
	long int tmp1,tmp2;
	int oi=0;
	char oc;
	int n;
	string cs;
	
	if(isNum(s[oi])==-1){s="+"+s;}
	
	while(1){
	 oc=s[oi];if(oc=='='){total+=work;break;}
	 
	 if(s[oi+1]!='('){	//??°???????????????
	  tmp1=0;
	  while(1){
	   oi++;
	   tmp2=s[oi];
	   if(tmp2!=-1){tmp1=tmp1*10+tmp2;}else{break;}
	  }
	 }else{	//??????????????°
	  cs="";n=1;oi++;
	  while(1){
	   oi++;
	   switch(s[oi]){
		case '(':n++;break;
		case ')':n--;break;
	   }
	   if(n!=0){cs+=s[oi];}else{break;}
	  }
	  cs+='=';
	  tmp1=hyoka(cs);
	 }
	
	 switch(oc){
	  case '+':total+=work;work=tmp1;break;
	  case '-':total+=work;work=-tmp1;break;
	  case '*':work*=tmp1;break;
	  case '/':work/=tmp1;break;
	 }
	}
	
	return total;
}

int isNum(int c){
	if(49<=c && c<=57){
	 return c-49;
	}
	return -1;
}

C++: #include"bits/stdc++.h"
using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int formula(string &s, int &i);
int term(string &s, int &i);
int factor(string &s, int &i);
int number(string &s, int &i);

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		int num = 0;
		cout << formula(s, num) << endl;
	}

	return 0;
}

int formula(string &s, int &i) {
	int res = term(s, i);
	if (s[i] == '+') {
		i++;
		return res + formula(s, i );
	}
	if (s[i] == '-') {
		i++;
		return res - formula(s, i );
	}
	return res;
}

int term(string &s, int &i) {
	int res = factor(s, i);
	while (s[i] == '*' || s[i] == '/') {
		char op = s[i];
		i++;
		if (op == '*') {
			res *= factor(s, i);
		}
		else {
			res /= factor(s, i);
		}
	}
	return res;
}

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

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

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

int num(string&, int&);
int fact(string&, int&);
int mul(string&, int&);
int expr(string&, int&);

int num(string &s, int &k) {
    int ret = 0;
    while ('0' <= s[k] && s[k] <= '9') {
        ret *= 10;
        ret += s[k] - '0';
        k ++;
    }
    return ret;
}

int fact(string &s, int &k) {
    int ret;
    if (s[k] == '(') {
        ret = expr(s, ++k);
        k ++;
    } else if (s[k] == '-') {
        ret = -num(s, ++k);
    } else if (s[k] == '+') {
        ret = num(s, ++k);
    } else {
        ret = num(s, k);
    }
    return ret;
}

int mul(string &s, int &k) {
    int ret = fact(s, k);
    while (1) {
        if (s[k] == '*') {
            ret *= fact(s, ++k);
        } else if (s[k] == '/') {
            ret /= fact(s, ++k);
        } else {
            break;
        }
    }
    return ret;
}

int expr(string &s, int &k) {
    int ret = mul(s, k);
    while (1) {
        if (s[k] == '+') {
            ret += mul(s, ++k);
        } else if (s[k] == '-') {
            ret -= mul(s, ++k);
        } else {
            break;
        }
    }
    return ret;
}

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