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 <string>
#include <algorithm>

using namespace std;

int p1( string const& expr, int& pos );
int p2( string const& expr, int& pos );
int p3( string const& expr, int& pos );

int p1( string const& expr, int& pos )
{
    int result = p2(expr, pos);
    if ( result == -1 )
        return -1;

    while( expr[pos] == '+' || expr[pos] == '-' ) {
        int const cp = pos;
        ++pos;
        int const a = p2( expr, pos );
        if ( expr[cp] == '+' )
            result += a;
        else
            result -= a;
    }

    return result;
}

int p2( string const& expr, int& pos )
{
    int result = p3(expr, pos);
    if ( result == -1 )
        return -1;

    while( expr[pos] == '*' || expr[pos] == '/' ) {
        int const cp = pos;
        ++pos;
        int const a = p3( expr, pos );
        if ( expr[cp] == '*' )
            result *= a;
        else
            result /= a;
    }

    return result;
}

int p3( string const& expr, int& pos )
{
    if ( expr[pos] >= '0' && expr[pos] <= '9' ) {
        int const cp = pos;
        ++pos;
        return expr[cp] - '0';

    } else if ( expr[pos] == '(' ){
        ++pos;
        int const res = p1( expr, pos );
        ++pos; // ')'
        return res;
    }

    return ~1;
}



int main()
{
    int n;
    cin >> n;
    cin.ignore();
    for( int iii=0; iii<n; ++iii ) {
        string s;
        getline( cin, s );
//        cout << s << endl;
        int pos = 0;
        cout << p1( s, pos ) << endl;
    }
}

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

using namespace std;

int number(const string &s, int &k);
int fact(const string &s, int &k);
int term(const string &s, int &k);

int expr(const string &s, int &k){
  int result = term(s,k);
  while(k < s.size()-1){
    if(s[k]=='+')return result + term(s,++k);
    else return result - term(s,++k);
  }
}

int term(const string &s, int &k){
  int res = fact(s,k);
  while(k<s.size()-1){
    if(s[k]=='*')return res * fact(s,++k);
    else if(s[k]=='/')return res / fact(s,++k);
    else return res;
  }
}

int fact(const string &s, int &k){
  if(s[k]=='('){
    int res = 0;    
    res = expr(s,++k);
    k++;
    return res;
  }
  return number(s,k);
}

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

int main(void){

  int n;
  cin >> n;

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

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

int p;
string str;

int Term();
int Factor();
int Elem();
int Digit();

int Term() {
  int a = Factor();
  while (str[p] == '+' || str[p] == '-') {
    char c = str[p];
    p++; // read [+-]
    int b = Factor();
    if (c == '+') {
      a = a + b;
    } else {
      a = a - b;
    }
  }
  return a;
}

int Factor() {
  int a = Elem();
  while (str[p] == '*' || str[p] == '/') {
    char c = str[p];
    p++; // read [*/]
    int b = Elem();
    if (c == '*') {
      a = a * b;
    } else {
      a = a / b;
    }
  }
  return a;
}

int Elem() {
  if (str[p] == '(') {
    p++; // read (
    int a = Term();
    p++; // read )
    return a;
  } else {
    int a = 0;
    while (isdigit(str[p])) {
      int b = Digit();
      a = 10 * a + b;
    }
    return a;
  }
}

int Digit() {
  int a = str[p] - '0';
  p++; // read [0-9]
  return a;
};

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> str;
    p = 0;
    cout << Term() << endl;
  }
}

C++: #include<iostream>
#include<string>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef int number;

int c;
string str;

number Z();
number Expr();
number Factor();
number Term();
number Num();

void debug(string str) {
//  cout << str << endl;
}

number Z() {
  debug("Z: " + str.substr(c));
  number ans = Expr();
  c++; // read =
  debug("Z(" + to_string(ans) + "): " + str.substr(c));
  return ans;
}

number Expr() {
  debug("Expr: " + str.substr(c));
  number val = Factor();
  int p;
  while (p = c, (str[p] == '+' || str[p] == '-')) {
    if (str[c] == '+') {
      c++; // read +
      number expr = Expr();
      val += expr;
    } else {
      // c++; // read -
      number expr = Expr();
      // val -= expr;
      val += expr;
    }
  }
  debug("Expr(" + to_string(val) + "): " + str.substr(c));
  return val;
}

number Factor() {
  debug("Factor: " + str.substr(c));
  number val = Term();
  int p;
  while (p = c, (str[p] == '*' || str[p] == '/')) {
    if (str[c] == '*') {
      c++; // read *
      number factor = Term();
      val *= factor;
    } else {
      c++; // read /
      number factor = Term();
      val /= factor;
    }
  }
  debug("Factor(" + to_string(val) + "): " + str.substr(c));
  return val;
}

number Term() {
  debug("Term: " + str.substr(c));
  if (str[c] == '-') {
    c++; // read -
    number term = Term();
    return -term;
  } else if (str[c] == '(') {
    c++; // read (
    number expr = Expr();
    c++; // read )
    return expr;
  } else {
    number num = Num();
    return num;
  }
}

number Num() {
  debug("Num: " + str.substr(c));
  number val = 0;
  while (isdigit(str[c])) {
    val = val * 10 + (str[c] - '0');
    c++;
  }
  debug("Num(" + to_string(val) + "): " + str.substr(c));
  return val;
}

int main() {
  int n;
  cin >> n;
  REP(i, n) {
    c = 0;
    cin >> str;
    cout << Z() << endl;
  }
}