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;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl;
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

string s;
string::iterator p;
int fact();
int term();
int exp();

int fact() {
  int x;
  string num;
  while(isdigit(*p)) {
    num += *p;
    ++p;
  }
  if(num.size()) {
    x = atoi(num.c_str());
  } else {
    ++p;
    x = exp();
    ++p;
  }
  return x;
}
 
int term() {
  int x = fact();
  while(*p == '*' || *p == '/') {
    if(*p == '*') {
      ++p;
      x *= fact();
    } else {
      ++p;
      x /= fact();
    }
  }
  return x;
 
}
 
int exp() {
  int x = term();
  while(*p == '+' || *p == '-') {
    if(*p == '+') {
      ++p;
      x += term();
    } else {
      ++p;
      x -= term();
    }
  }
  return x;
}

int main() {
  int n;
  cin >> n;
  while(n--) {
    cin >> s;
    p = s.begin();
    cout << exp() << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
#define range(i,x,y) i=(x);i<(y);i++
#define rep(i,n) for(int i=0,i##_len=n;i<i##_len;i++)
#define all(x) begin(x),end(x)
#define lim(x,r,l) (r<=x&&x<l)
typedef long long ll;
typedef long double ld;
using namespace std;

int c = -1;
string s;


/*
<eq> = <expr> '='
<expr> = <expr2> (('+'|'-') <expr2>)*
<expr2> = <expr3> (('*'|'/') <expr3>)*
<expr3> = <number> | '(' <expr> ')'
<number> = ['0' - '9']+
*/

char seek(){
  assert(c < s.size());
  return s[c];
}
char next(){
  assert(c < s.size());
  char res = s[c];
  c++;
  return res;
}
int number(){
  int res = 0;
  if(isdigit(seek())){
    res *= 10;
    res += next() - '0';
  }
  return res;
}
int expr();

int expr3(){
  char p = seek();
  if(p == '('){
    next();
    int res = expr();
    assert(next() == ')');
    return res;
  }
  return number();
}
int expr2(){
  int res = expr3();
  while(true){
    char op = seek();
    if(op == '*'){
      next();
      int other = expr2();
      res *= other;
    }else if(op == '/'){
      next();
      int other = expr2();
      res /= other;
    }else{
      return res;
    }
  }
}
int expr(){
  int res = expr2();
  while(true){
    char op = seek();
    if(op == '+'){
      next();
      int other = expr2();
      res += other;
    }else if(op == '-'){
      next();
      int other = expr2();
      res -= other;
    }else{
      return res;
    }
  }
}

int eq(){
  int e = expr();
  char eqa = next();
  assert(eqa == '=');
  return e;
}
int solve(string str){
  c = 0;
  s = str;
  return eq();
}
signed main(){
  int n; cin >> n;
  rep(i,n){
    string str; cin >> str;
    cout << solve(str) << endl;
  }
}

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

typedef int Val;
typedef pair<Val,int> Res;
#define val first
#define idx second

Res readExpr(string &s, int idx);
Res readTerm(string &s, int idx);
Res readFctr(string &s, int idx);

Res readQuery(string &s, int idx){
  //cout << "Q[";
  Res r = readExpr(s, idx);
  // skip '=';
  //cout << "]";
  return r;
}
Res readExpr(string &s, int idx){
  //cout << "E[";
  Res r = readTerm(s, idx);
  while (s[r.idx]=='+' || s[r.idx]=='-'){
    Res r2 = readTerm(s, r.idx+1);
    if (s[r.idx]=='+') r.val += r2.val;
    else r.val -= r2.val;
    r.idx = r2.idx;
  }
  //cout << "]";
  return r;
}
Res readTerm(string &s, int idx){
  //cout << "T[";
  Res r = readFctr(s, idx);
  while (s[r.idx]=='*' || s[r.idx]=='/'){
    Res r2 = readFctr(s, r.idx+1);
    if (s[r.idx]=='*') r.val *= r2.val;
    else r.val /= r2.val;
    r.idx = r2.idx;
  }
  //cout << "]";
  return r;
}
Res readFctr(string &s, int idx){
  Res r;
  //cout << "F[";
  if (s[idx]=='('){
    r = readExpr(s, idx+1);
    r.idx++; // skip ')'
  } else {
    int sgn=1,num=0;
    if (s[idx]=='-'){
      sgn=-1;
      idx++;
    }
    while (s[idx]>='0'&&s[idx]<='9'){
      num = num*10 + (s[idx]-'0');
      idx++;
    }
    r.val = num*sgn; r.idx = idx;
  }
  //cout<<"]";
  return r;
}

int main(void){
  int n;
  cin >> n;
  for (int i=0; i<n; i++){
    string str; cin >> str;
    cout << readQuery(str,0).val << endl;
  }
  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 <cctype>
#include <cassert>
#include <iostream>
using namespace std;
string S;
size_t cur; //?§£???????§???????
int digit() {
  assert(isdigit(S[cur])); //S[cur]?????°?????§???????????¨????¢????
  int n = S[cur] - '0'; // '0'???0?????????
  cur = cur + 1; //??????????????????
  return n;
}
int number() {
  int n = digit();
  while(cur < S.size() && isdigit(S[cur])) { //?¬??????°??????1???????????????
    n = n*10 + digit();
  }
  return n;
}
int expression(); //????????£?¨?
int factor() {
  if(S[cur] != '(') {
    return number();
  }
  cur += 1;
  int n = expression ();
  assert(S[cur] == ')');
  cur +=1;
  return n;
}
int term() {
  int a = factor();
  while(cur < S.size() && (S[cur] == '*' || S[cur] == '/')) {
    char op = S[cur++];
    int b = factor();
    if(op == '*') {
      a *= b;
    }
    else {
      a /= b;
    }
  }
  return a;
}
int expression() {
  int a = term();
  while(cur < S.size() && (S[cur] == '+' || S[cur] =='-')) { //?¶???????????????????????¶???????
    char op = S[cur++];
    int b = term();
    assert(op == '+' || op == '-');
    if(op == '+') {
      a += b;
    }
    else {
      a -= b;
    }
  }
  return a;
}
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;
  }
}