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++: //?????????
//??????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 <iostream>
#include <string>
#include <cctype>

using namespace std;

int expr(string& s, int& i);
int term(string& s, int& i);
int factor(string& s, int& i);
int number(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 number(s, i);

    // ここで構文が正しければ s[i] == '(' となる
    i++; // '('を読み飛ばす
    int ret = expr(s, i);
    i++; // ')'を読み飛ばす
    return ret;
}

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

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string str;
        cin >> str;
        int j = 0;
        cout << expr(str, j) << endl;
    }

    return 0;
}