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 <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <cctype>

using namespace std;

using State = string::const_iterator;

int number(State &begin);
int expression(State &begin);
int term(State &begin);
int factor(State &begin);

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

    return ret;
}

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

int expression(State &begin){
    int ret = term(begin);

    while(true){
        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);

    while(true){
        if(*begin == '*'){
            begin++;
            ret *= factor(begin);
        }
        else if(*begin == '/'){
            begin++;
            ret /= factor(begin);
        }
        else{
            break;
        }
    }

    return ret;
}

int main(){

    int N;
    cin >> N;
    string s;
    for(int i = 0; i < N; i++){
        cin >> s;
        State begin = s.begin();
        cout << expression(begin) << endl;
    }

    return 0;
}

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

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

int main()
{
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      s.erase(s.end()-1);
      int p = 0;
      cout << exp(s, p) << endl;
    }
  }
  return 0;
}

int exp(const string& s, int& p)
{
  int ret = term(s, p);
  for ( ; ; ) {
    if (s[p] == '+')
      ret += term(s, ++p);
    else if (s[p] == '-')
      ret -= term(s, ++p);
    else
      break;
  }
  return ret;
}

int term(const string& s, int& p)
{
  int ret = fact(s, p);
  for ( ; ; ) {
    if (s[p] == '*')
      ret *= fact(s, ++p);
    else if (s[p] == '/')
      ret /= fact(s, ++p);
    else
      break;
  }
  return ret;
}

int fact(const string& s, int& p)
{
  int ret = 0;
  if (s[p] == '(') {
    ret = exp(s, ++p);
    ++p;
  } else {
    ret = number(s, p);
  }
  return ret;
}

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

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

using namespace std;
int cur = 0;
string S;
int expression();
int term();
int main() {
  int times;
  cin >>times;
  for(int i = 0 ; i < times; i++){
      cin >> S;
      cur = 0;
      S.resize(S.size()-1);
      cout << expression() <<endl;
  }

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