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 <stack>
#include <map>
#include <cstdlib>
#include <cctype>
#include <cstdio>
#include <cstring>

using namespace std;

int str2arr(char s[], string A[]) {
    bool flag = true;
    string t;
    int l = strlen(s);
    int n = 0;
    for (int i = 0; i < l; i++) {
        if (isdigit(s[i]) && flag) {
            t = "";
            int j = 0;
            while (isdigit(s[i+j])) {
                t += s[i+j];
                if (i+j == l-1)
                    break;
                j++;
            }
            A[n++] = t;
            flag = false;
        }
        else if (!isdigit(s[i])) {
            A[n++] = s[i];
            flag = true;
        }
    }
    return n;
}

int Generate_RPN(int n, string A[], string B[]) {
    map<string, int> table;
    table["*"] = 1;
    table["/"] = 1;
    table["+"] = 0;
    table["-"] = 0;
    table["("] = -1;
    table[")"] = -1;
    stack<string> S;
    int j = 0;

    for (int i = 0; i < n; i++) {
        if (isdigit(A[i][0])) {
            B[j++] = A[i];
        }

        else if (A[i] == "(")
            S.push(A[i]);

        else if (A[i] == ")") {
            while (S.top() != "(") {
                B[j++] = S.top();
                S.pop();
            }
            S.pop();
        }
        else {
            while ((!S.empty()) && (table[S.top()] >= table[A[i]])) {
                B[j++] = S.top();
                S.pop();
            }
            S.push(A[i]);
        }
    }
    while (!S.empty()) {
        B[j++] = S.top();
        S.pop();
    }
    return j;
}

int Calculate_RPN(int n, string s[]) {
    stack<double> St;
    double a, b;

    for (int i = 0; i < n; i++) {
        if (s[i] == "+") {
            b = int(St.top()); St.pop();
            a = int(St.top()); St.pop();
            St.push(a+b);
        }
        else if (s[i] == "-") {
            b = int(St.top()); St.pop();
            a = int(St.top()); St.pop();
            St.push(a-b);
        }
        else if (s[i] == "*") {
            b = int(St.top()); St.pop();
            a = int(St.top()); St.pop();
            St.push(a*b);
        }
        else if (s[i] == "/") {
            b = int(St.top()); St.pop();
            a = St.top(); St.pop();
            St.push(a/b);
        }
        else {
            St.push(atoi(s[i].c_str()));
        }
    }
    return int(St.top());
}

int main()
{
    int n, l, t;
    string A[101], B[101];
    char s[101];

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%s", s);
        s[strlen(s)-1] = '\0';

        l = str2arr(s, A);
        t = Generate_RPN(l, A, B);

        cout << Calculate_RPN(t, B) << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;

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

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

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

int factor(string &s, int&i) {
	if (isdigit(s[i])) return num(s, i);
	else {
		++i;
		int val= expr(s, i);
		++i;
		return val;
	}
}
int num(string &s, int&i) {
	int a;
	if (isdigit(s[i])) {
		a = s[i] - '0';
		++i;
		while (isdigit(s[i])) {
			a = a * 10 + (s[i] - '0');
			++i;
		}
	}
	return a;
}
int main() {
	int n;
	cin >> n;
	REP(i, n) {
		string s;
		cin >> s;
		s = s.substr(0, s.size() - 1);
		int index = 0;
		int ans = expr(s, index);
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int exp();
int term();
int factor();
int number();
int digit();
int p=0;
string str;
int cnt=0;
int main(){
  int n,re;
  cin >> n;
  while(n){
    p=0;
    cin >> str;
    re=exp();
    cout << re << endl;
    n--;
  }
  return 0;
}
int exp(){
  int val=term();
  while(str[p]=='+'||str[p]=='-'){
    if(str[p]=='+'){
      p++;
      val+=term();
    }else if(str[p]=='-'){
      p++;
      val-=term();
    }
  }
  return val;
}
int term(){
  int val=factor();
  while(str[p]=='*'||str[p]=='/'){
    if(str[p]=='*'){
      p++;
      val*=factor();
    }else if(str[p]=='/'){
      p++;
      val/=factor();
    }
  }
  return val;
}
int factor(){
  int val=number();
  if(str[p]=='('){
    p++;
    val=exp();
  }else if(str[p]==')'){
    p++;
  }
  return val;
}
int number(){
  int val=digit();
  return val;
}
int digit(){
  int ret,cnt=0;
  while(1){
    if(cnt==0&&'0'<=str[p]&&str[p]<='9'){
      ret=str[p]-'0';
      p++;
      cnt=1;
    }
    else if(cnt==1&&'0'<=str[p]&&str[p]<='9'){
      ret=ret*10+(str[p]-'0');
      p++;
    }
    else{
      break;
    }
  }
  /*  if('0' <= str[p] && str[p] <= '9') {
    if(cnt==0){
      ret=str[p]-'0';
      cnt=1;
    }
    p++;
    if('0' <= str[p] && str[p] <= '9') {
      ret=ret*10+(str[p]-'0');
      digit();
    }
    return ret;
    }*/
  return ret;
}