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 <stack>

using namespace std;

int pri(char ch) 
{
    if (ch == '*' || ch == '/')
        return 2;
    if (ch == '+' || ch == '-')
        return 1;
    else
        return 0;
}

int main()
{
    int n;

    cin >> n;

    while (n--) {
        string exp, cha;
        stack<char> pol;
        stack<int> cal;

        cin >> exp;
        for (int i = 0; i < exp.size() - 1; i++) {
            if ('0' <= exp[i] && exp[i] <= '9') {
                while (true) {
                    cha.push_back(exp[i]);
                    if ('0' > exp[i + 1] || exp[i + 1] > '9') {
                        cha.push_back('.');
                        break;
                    }
                    else
                        i++;
                }
            }
            else if (exp[i] == '(')
                pol.push(exp[i]);
            else if (exp[i] == ')') {
                while (true) {
                    if (pol.top() == '(') {
                        pol.pop();
                        break;
                    }
                    cha.push_back(pol.top());
                    pol.pop();

                }
            }
            else {
                while (!pol.empty()) {
                    if (pri(exp[i]) < pri(pol.top())) {
                        cha.push_back(pol.top());
                        pol.pop();
                    }
                    else 
                        break;
                }
                pol.push(exp[i]);
            }
        }

        while (!pol.empty()) {
            cha.push_back(pol.top());
            pol.pop();
        }

        for (int i = 0; i < cha.size(); i++) {
            if ('0' <= cha[i] && cha[i] <= '9') {
                int tmp = cha[i] - '0';

                while (true) {
                    i++;
                    if (cha[i] == '.') 
                        break;
                    tmp *= 10;
                    tmp += cha[i] - '0';
                }
                cal.push(tmp);
            }
            else {
                int a, b;

                b = cal.top();
                cal.pop();
                a = cal.top();
                cal.pop();

                if (cha[i] == '*') 
                    cal.push(a * b);
                else if (cha[i] == '/') 
                    cal.push(a / b);
                else if (cha[i] == '+') 
                    cal.push(a + b);
                else if (cha[i] == '-') 
                    cal.push(a - b);
            }
        }
        cout << cal.top() << endl;
    }

    return 0;
}

C++: // 構文解析の練習
// https://gist.github.com/draftcode/1357281
#include <cctype>
#include <string>
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef string::const_iterator State;
class ParseError{};
int number(State&);
int term(State&);
int expression(State&);
int factor(State&);

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

    while(1) {
        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);
    
    while(1) {
        if(*begin == '+') {
            begin++;
            ret += term(begin);
        }
        else if(*begin == '-') {
            begin++;
            ret -= term(begin);
        }
        else {
            break;
        }
    }
    return ret;

}
int factor(State& begin) {
    int ret = 0;
    if(*begin == '(') {
        begin++; // ( を飛ばす
        ret = expression(begin);
        begin++; // ) を飛ばす
    }
    else {
        ret = number(begin);
    }

    return ret;
}

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

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int expression();
int term();
int factor();
int number();

int now;
string s;

int expression(){
	int res=term();
		while(true){
		if(s[now]=='+')now++,res+=term();
		else if(s[now]=='-')now++,res-=term();
		else break;
	}
	return res;
}

int term(){
	int res=factor();
	while(true){
		if(s[now]=='(')res+=factor();
		else if(s[now]=='*')now++,res*=factor();
		else if(s[now]=='/')now++,res/=factor();
		else break;
	}
	return res;
}

int factor(){
	int res=0;
	if(s[now]=='('){
		now++;
		res=expression();
		now++;
	}
	else return number();
	
	return res;
}

int number(){
	int res=0;
	while('0'<=s[now] && s[now]<='9'){
		res*=10;
		res+=s[now++]-'0';
	}
	return res;
}


int main(void){
	int n;
	cin >> n;
	
	while(n--){
		cin >> s;
		now=0;
		cout << expression() << endl;
	}
	
	return 0;
}