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<algorithm>
#include<vector>
#include<cassert>
#include<cstdio>
#include<queue>
#include<cctype>
#include<math.h>

using namespace std;

string S;
size_t cur = 0;

int digit(){
	assert(isdigit(S[cur]));
	int n = S[cur] - '0';
	cur = cur + 1;
	return n;
}

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

int term(){
	int a = number();
	while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')){
		char op = S[cur++];
		int b = number();
		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 = number();
		if (op == '+') a += b; else a -= b;
	}
	return a;
}

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

int main(){
	int N;
	scanf("%d", N);
	for (int i = 0; i < N; i++){
		cur = 0;
		scanf("%s", S);
		S.resize(S.size() - 1);
		cout << factor() << endl;
	}
}

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

int pos;
string str;

int exp();

int factor() {
  if(str[pos] >= '0' && str[pos] <= '9') {
    string tmp = "";
    while(str[pos] >= '0' && str[pos] <= '9') {
      tmp += str[pos++];
    }
    return atoi(tmp.c_str());
  }

  if(str[pos] == '(') {
    pos++;
    int tmp = exp();
    pos++;
    return tmp;
  }
}

int term() {
  int x = factor();
  while(str[pos] == '*' || str[pos] == '/') {
    if(str[pos] == '*') {
      pos++;
      x *= factor();
    } else if(str[pos] == '/') {
      pos++;
      x /= factor();
    }
  }
  return x;
}

int exp() {
  int x = term();
  while(str[pos] == '+' || str[pos] == '-') {
    if(str[pos] == '+') {
      pos++;
      x += term();
    } else if(str[pos] == '-') {
      pos++;
      x -= term();
    }
  }
  return x;
}

main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    pos = 0;
    cin >> str;
    str = str.substr(0, str.length()-1);
    cout << exp() << endl;
  }
}

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

/** memo
 * expr ::= term { ( '+' | '-' ) term }
 * term ::= fact { ( '*' | '/' ) fact }
 * fact ::= '(' expr ')' | digit
 **/

using namespace std;

int expr();
int term();
int fact();

char buf[101];
int p;

int expr() {
	int v = term();
	while(buf[p] == '+' || buf[p] == '-') {
		if(buf[p] == '+') {
			p++;
			v += term();
		}
		else {
			p++;
			v -= term();
		}
	}
	return v;
}


int term() {
	int v = fact();
	while(buf[p] == '*' || buf[p] == '/') {
		if(buf[p] == '*') {
			p++;
			v *= fact();
		}
		else {
			p++;
			v /= fact();
		}
	}
	return v;
}

int fact() {
	int v = 0;
	if(buf[p] == '(') {
		p++;
		v = expr();
		p++; // skip ')'
	}
	else {
		while(isdigit(buf[p])) {
			v = v * 10 + buf[p] - '0';
			p++;
		}
	}
	return v;
}

int main() {
	int times;
	int ans;

	cin >> times;
	for(int i = 0; i < times; i++) {
		cin >> buf;
		p = 0;
		ans = expr();
		cout << ans << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
using namespace std;
#define INF (1<<25)
#define P(a,b) make_pair(a,b)

int id = 0;
string s;

int exp();
int term();
int fact();

int exp(){
	int ans = term();
	while(true){
		char c = s[id++];
		if(c == '+'){
			ans += term();
		}else if(c=='-'){
			ans -= term();
		}else{
			return ans;
		}
	}
}
int term(){
	int ans = fact();
	while(true){
		char c = s[id++];
		if(c == '*'){
			ans *= fact();
		}else if(c=='/'){
			ans /= fact();
		}else{
			id--;
			return ans;
		}
	}
	
}
int fact(){
	char c = s[id++];
	if(c=='(') return exp();
	if(c=='-') return -exp();
	if(c=='+') return  exp();
	int x = c - '0';
	while(true){
		c = s[id++];
		if('0' <= c && c <= '9'){
			x = x*10 + c - '0';
		}else{
			id--;
			return x;
		}
	}
}
int main(){
	int n;
	cin >> n;
	while(n--){
		cin >> s;
		id = 0;
		cout << exp() << endl;
	}
}

C++: #include<iostream>
#include<cstdio>
#include<cctype>
#include<string>
using namespace std;
int pos;
string parse;
/*
class Parsing{
private:
  string parse;
  int pos;
public:

  Parsing(string s){
    parse = s;
    pos = 0;
  }
*/

int fact();
int term();
int expression();

  int fact(){
    if(parse[pos] == '('){
      pos++;
      int p = expression();
      pos++;
      return p;
    }else{
      int p = 0;
      while('0' <= parse[pos] && parse[pos] <= '9'){
	p *= 10;
	p += parse[pos]-'0';
	pos++;
      }
      return p;
    }
  }

 int term(){
    int p = fact();
    while(parse[pos] == '*' || parse[pos] == '/'){
      if(parse[pos] == '*'){++pos;p *= term();}
      else {++pos;p /= term();}
    }
    return p;
  }

 int expression(){
    int p = term();
    while(parse[pos] == '+' || parse[pos] == '-'){
      if(parse[pos] == '+'){++pos;p+=term();}
      else {++pos;p-=term();}
    }
    return p;
  } 
 
/*
};
*/







int main(){
  string s;
  int N;
  cin >> N;
  while(N-- > 0){
    pos = 0;
    cin >> s;
    parse = s.substr(0,s.length()-1);
   
    //Parsing par = Parsing(s.substr(0,s.length()-1));
    //cout << par.expression() << endl;
    cout << expression() << endl;
  }
  return 0;
}