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 <map>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
using namespace std;

int calculate(string expr) {
	map<char,int> op_pd {{'+',0},{'-',0},{'*',1},{'/',1}}; // operator precedence
	vector<string> pf; // postfix expression
	stack<char> op_s;
	// turn infix to postfix
	string unit;
	for (char ch : expr) {
		if (ch >= '0' && ch <= '9') {
			unit.push_back(ch);
		} else {
			if (!unit.empty()) {
				pf.push_back(unit);
				unit.clear();
			}
			if (ch == '(') {
				op_s.push('(');
			} else if (ch == ')') {
				while (op_s.top() != '(') {
					pf.push_back(string().assign(1,op_s.top()));
					op_s.pop();
				}
				op_s.pop();
			} else { // '+','-','*','/'
				while (!op_s.empty() && op_s.top() != '(' && op_pd[ch] <= op_pd[op_s.top()]) {
					pf.push_back(string().assign(1,op_s.top()));
					op_s.pop();
				}
				op_s.push(ch);
			}
		}
	}
	if (!unit.empty()) {
		pf.push_back(unit);
	}
	while (!op_s.empty()) {
		pf.push_back(string().assign(1,op_s.top()));
		op_s.pop();
	}
	// calculate the postfix expression
	stack<int> num_s;
	num_s.push(stoi(pf.front()));
	for (auto i = pf.begin() + 1;i != pf.end();++i) {
		if (i->front() >= '0' && i->front() <= '9') {
			num_s.push(stoi(*i));
		} else {
			int second = num_s.top();
			num_s.pop();
			int first = num_s.top();
			num_s.pop();
			switch (i->front()) {
				case '+':
					num_s.push(first + second);
					break;
				case '-':
					num_s.push(first - second);
					break;
				case '*':
					num_s.push(first*second);
					break;
				default: // '/'
					num_s.push(first/second);
			}
		}
	}
	return num_s.top();
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		string expr;
		cin >> expr;
		cout << calculate(expr.substr(0,expr.size()-1)) << endl;
	}
}

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 i, n = 0;
    for (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;
}

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

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

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

    scanf("%d", &n);

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

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

        calculate(t, B);
    }

    return 0;
}