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>

using namespace std;

void str2arr(string s, string A[]) {
    int n = 0;
    string tmp = "";

    for (int i = 0; s[i] != '=' ; i++) {
        if ('0' <= s[i] && s[i] <= '9') {
            tmp += s[i];
        }
        else {
            if (tmp != "") { 
                A[n++] = tmp;
                tmp = "";
            }
            A[n++] = s[i];
        }
    }
    if (tmp != "") { A[n++] = tmp; }
    A[n++] = "=";
}

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

    int j = 0;
    for (int i = 0; A[i] != "="; i++) {
        if ('0' <= A[i][0] && A[i][0] <= '9') {
            B[j++] = A[i];
        }
        else if (A[i] == "(") {
            St.push(A[i]);
        }
        else if (A[i] == ")") {
            while (St.top() != "(") {
                B[j++] = St.top(); St.pop();
            }
            St.pop();
        }
        else {
            while ((!St.empty()) && (table[St.top()] >= table[A[i]])) {
                B[j++] = St.top(); St.pop();
            }
            St.push(A[i]);
        }
    }
    while (!St.empty()) {
        B[j++] = St.top(); St.pop();
    }
    B[j] = "=";
}

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

    for (int i = 0; s[i] != "="; 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;
    string A[100], B[100];
    string in;

    cin >> n;

    while (n--) {
        cin >> in;
        str2arr(in, A);
        Generate_RPN(A, B);
        cout << Calculate_RPN(B) << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cassert>

using namespace std;

#define REP(var, count) for(int var=0; var<count; var++)

const char op[] = "()*/+-=N";


string line;
int cur;
char readchar() {
	return line[cur++];
}
char peek() {
	return line[cur];
}


int digit() {
	return readchar() - '0';
}
int number() {
	int n = digit();
	while ( peek() >= '0' && peek()<='9' ) {
		n = n*10 + digit();
	}
	return n;
}

int expression();
int factor() {
	if ( peek() != '(' ) { return number(); }
	assert( readchar() == '(' );
	int ret = expression();
	assert( readchar() == ')' );
	
	return ret;
}

int term() {
	int ret = factor();
	while( peek() == '*' || peek() == '/' ) {
		char op = readchar();
		int fac = factor();
		
		if ( op == '*' ) { ret *= fac; }
		else { ret /= fac; }
	}
	
	return ret;
}

int expression() {
	int ret = term();
	while( peek() == '+' || peek() == '-' ) {
		char op = readchar();
		int ter = term();
		
		if ( op == '+' ) { ret += ter; }
		else { ret -= ter; }
	}
	
	return ret;
}

int main(void) {
	int N;
	cin >> N;
	while(N--) {
		cin >> line;
		cur = 0;
		
		cout << expression() << endl;
	}

}

C++: //?????????
//??????00-440415D???Smart_Calculator.cpp

#include <iostream>
#include <string>
#include <cassert>
#include <cctype>
#include <stdio.h>

using namespace std;

string S = "1+2*(3+4)";
size_t cur = 0;

int expression();

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

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

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

//??????????????????????????????
int term(){
	int a = factor();
	while(cur < S.size() && (S[cur] == '*' || S[cur] == '/')){
		char op = S[cur++];
		int b = factor();
		if(op == '*'){
			a *= b;
		}else if(op == '/'){
			a /= b;
		}
	}
	return a;
}

int expression(){
	int sum = term();
	while(S[cur] == '+' || S[cur] == '-'){
		char op = S[cur++];
		int b = term();
		if(op == '+'){
			sum += b;
		}else if(op == '-'){
			sum -= b;
		}
	}
	return sum;
}

int main(){
	int N;
	cin >> N;
	for(int i=0; i<N; i++){
		cur = 0;
		cin >> S;
		S.resize(S.size-1);
		cout << expression() << endl;
	}
	return 0;
}

C++: #include <string>
#include <cctype>
#include <iostream>
typedef std::string::const_iterator State;
class ParseError {};

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

int main(void){
	int N;
	std::cin >> N;
	std::cin.ignore();
	for(int i = 0; i < N; ++i){
		std::string s;
		std::getline(std::cin, s);
		State begin = s.begin();
		int ans = expression(begin);
		std::cout << ans << std::endl;
	}
	return 0;
}

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++;
	}else{
		return number(begin);
	}
}

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

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

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

	for(;;){
		if(*begin == '+'){
			begin++;
			ret += term(begin);
		} else if(*begin == '-'){
			begin++;
			ret -= term(begin);
		}else {
			break;
		}
	}
	return ret;
}