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>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

int expr(string &s, int &i){
    int val = term(s, i);          // <term>
    while(s[i] == '+' || s[i] == '-'){  // [
        char opr = s[i];            // ('+' | '-')
        ++i;
        int val2 = term(s, i);      // <term>
        if(opr == '+') val += val2;
        else val -= val2;
    }                               // ]*
    return val;
}

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

int factor(string &s, int &i){
    if(isdigit(s[i])) return number(s, i);
    ++i;    // '('
    int val = expr(s, i);
    ++i;    // ')'
    return val;
}

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


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    REP(x, N){
        string s;
        s = s.substr(0, s.size()-1);
        cin >> s;
        int i = 0;
        cout << expr(s, i) << "\n";
    }
    return 0;
}

C++: #include <string>
#include <cctype>
#include <iostream>
typedef std::string::const_iterator State;
class ParseError {};

int number(State &begin);
int factor(State &begin);
int term(State &begin);
int expression(State &begin);
void consume(State &begin, char expected){
	if(*begin == expected){
		begin++;
	}else{
		std::cerr << "Expected '" << expected << "' but got '"<<*begin << "'"<<std::endl;
		std::cerr << "Rest string is '";
		while(*begin){
			std::cerr << *begin++;
		}
		std::cerr<<"'"<<std::endl;
		throw ParseError();
	}
}

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

int number(State &begin){
	int ret = 0;

	while(isdigit(*begin)){
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}

	return ret;
}

int factor(State &begin){
	if(*begin == '('){
		consume(begin,'(');
		int ret = expression(begin);
		consume(begin,')');
	}else{
		return number(begin);
	}
}

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 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;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

// <四則演算> ::= <乗除算> | <四則演算> + <乗除算> | <四則演算> - <乗除算>
// <乗除算>   ::= <括弧か数> | <乗除算> * <括弧か数> | <乗除算> / <括弧か数>
// <括弧か数> ::= ( <四則演算> ) | <数>
// <数>       ::= [数]

typedef string::const_iterator State;
class ParseError {};

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

// 四則演算の式
int expr(State &begin)
{
    int ret = term(begin);
    while (true) {
        if (*begin == '+') {
            begin++; // skip '+'
            ret += term(begin);
        } else if (*begin == '-') {
            begin++;
            ret -= term(begin);
        } else {
            break;
        }
    }
    return ret;
}


// 乗除算
int term(State &begin)
{
    int ret = factor(begin);
    while (true) {
        if (*begin == '*') {
            begin++;
            ret *= factor(begin);
        } else if (*begin == '/') {
            begin++;
            ret /= factor(begin);
        } else {
            break;
        }
    }
    return ret;
}


// 括弧か数
int factor(State &begin)
{
    if (*begin == '(') {
        begin++; // skip '('
        int ret = expr(begin);
        begin++; // skip ')'
        return ret;
    } else {
        return number(begin);
    }
}


// 数字
int number(State &begin)
{
    int ret = 0;
    while (isdigit(*begin)) {
        ret *= 10;
        ret += (*begin - '0');
        begin++;
    }
    return ret;
}


int main()
{
    int N; cin >> N;
    rep(i, N) {
        string S; cin >> S;
        State begin = S.begin();
        cout << expr(begin) << endl;
    }
}

C++: #include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
LL plusub(void);
LL muldiv(void);
LL parent(void);
LL number(LL a);

int ind;
string str;

LL plusub(void){
  LL a=muldiv();
  if(str[ind]=='+'){
    ++ind;
    return a+plusub();
  }else if(str[ind]=='-'){
    ++ind;
    return a-plusub();
  }else return a;
}

LL muldiv(void){
  LL a=parent();
  if(str[ind]=='*'){
    ++ind;
    return a*muldiv();
  }else if(str[ind]=='/'){
    ++ind;
    return a/muldiv();
  }else return a;
}

LL parent(void){
  if(str[ind]=='('){
    ++ind;
    LL a=plusub();
    ++ind;
    return a;
  }else return number(0);
}

LL number(LL a){
  if('0'<=str[ind] && str[ind]<='9'){
    LL b=str[ind]-'0';
    ++ind;
    return number(a*10+b);
  }else return a;
}

int main(void)
{
  int n;
  cin >> n;
  REP(i,n){
    ind=0;
    cin >> str;
    cout << plusub() << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <cassert>
#include <cctype>
using namespace std;
string S="";
int cur=0;
char readchar()
{
  assert(cur<S.size());
  return S[cur++];
}

char peek()
{
  assert(cur<S.size());
  return S[cur];
}

int digit()
{
  assert(isdigit(peek()));
  int n=readchar()-'0';
  return n;
}

int number()
{
  int n=digit();
  while(cur<S.size()&&isdigit(peek()))
  {
    n=n*10+digit();
  }
  return n;
}

int expression();

int factor()
{
  if(peek()!='(') return number();
  cur+=1;
  int n=expression();
  assert(peek()==')');
  cur+=1;
  return n;
}

int term()
{
  int a=factor();
  while(cur<S.size()&&(peek()=='*'||peek()=='/'))
  {
    char op=readchar();
    int b=factor();
    if(op=='*')
    {
      a*=b;
    }
    else
    {
      a/=b;
    }
  }
  return a;
}

int expression()
{
  int sum=term();
  while(cur<S.size()&&(peek()=='+'||peek()=='-'))
  {
    char op=readchar();
    int b=term();
    if(op=='+')
    {
      sum+=b;
    }
    else
    {
      sum-=b;
    }
  }
  return sum;
}



int main()
{
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cur=0;
    cin>>S;
    S.resize(S.size()-1);
    cout<<expression()<<endl;
  }
  return 0;
}