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;
    for (; isdigit(s[i]); i++) {
        res *= 10;
        res += s[i] - '0';
    }
    return res;
}

int factor(const string& s, int& i) {
    if (isdigit(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>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <list>
#include <iomanip>
#include <set>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
const int MOD=1000000007;
const int INF=1000000000;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;

class Parser{
public:

  int number(State &begin)
  {
    int ret=0;
    while(isdigit(*begin))
      {
	ret*=10;
	ret+=*begin-'0';
	begin++;
      }
    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;
  }

  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 factor(State &begin)
  {
    int ret;
    if(*begin=='(')
      {
	begin++;
        ret=expression(begin);
	begin++;
      }
    else
      {
	ret=number(begin);
      }
    return ret;
  }
};


int main(int argc,char const* argv[])
{
  int n;
  cin >> n;
  cin.ignore();
  for(int data=0;data<n;data++)
    {
      Parser ps;
      string s;
      getline(cin,s);
      State begin=s.begin();
      int ans=ps.expression(begin);
      cout << ans << endl;
    }
  return 0;
}

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

using namespace std;

int main()
{
int n;
string expr;

cin >> n;
for  (int i = 0; i < n; i++){
    cin >> expr;
    cerr << expr << endl;
}
return (0);
}

C++: #include <stdio.h>
#include <assert.h>
#include <stack>

char buf[128];
int pos;
#define NOW (buf[pos])

bool isdigit(char c) {
	return ('0' <= c && c <= '9');
}

bool isstrong(char c) {
	return (c=='*'||c=='/');
}
bool isweak(char c) {
	return (c=='+'||c=='-');
}

int digit() {
	if ( !isdigit(NOW) ) {
		fprintf(stderr, "%c: ", NOW);
		assert( isdigit(NOW) );
	}
	int ret = NOW - '0';
	pos++;
	
	return ret;
}
int number() {
	int ret = digit();
	while( isdigit(NOW) ) {
		ret = ret*10 + digit();
	}
	return ret;
}

int main(void) {

	int set;
	scanf("%d", &set);
	
	while(set--) {
		scanf("%s", buf);
		pos = 0;
		
		std::stack<char> expr;
		std::stack<int>  num;
		
		expr.push('(');
		
		while(true) {
			if(isdigit(NOW)) {
				num.push( number() );
			} else {
				if ( expr.top() == '(' && (NOW==')'||NOW=='=') ) {
					//対応する括弧が出てきたので、スタック上の括弧を消す
					expr.pop();
					pos++;
					if ( expr.empty() ) {
						break;
					}
				} else if ( expr.top() == '(' ||
				     NOW == '(' ||
					 ( isstrong(NOW)&&isweak(expr.top()) ) ) {
					//強い演算子はスタックに積んでおく。括弧が積んであるなら、無条件に積む
					expr.push(NOW);
					pos++;
				} else {
					//次の演算子は弱いor同じだから、積んでるものを先に計算してしまおう
					char de = expr.top(); expr.pop();

					int b = num.top(); num.pop();
					int a = num.top(); num.pop();
					int ans;
					switch(de) {
						case '+': ans=a+b; break;
						case '-': ans=a-b; break;
						case '*': ans=a*b; break;
						case '/': ans=a/b; break;
					}
					num.push(ans);
				}
			}
			
		}
		
		printf("%d\n", num.top());
	}
	
}