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++: //https://gist.github.com/draftcode/1357281
#include <string>
#include <cctype>
#include <iostream>
typedef std::string::iterator State;
class ParseError {};

int number(State &begin);
int factor(State &begin);
int term(State &begin);
int expression(State &begin);
void consume(State &begin, char expected){
	if(*begin == expected){
		begin++;
	}else{
		std::cerr << "Expected '" << expected << "' but got '"<<*begin << "'"<<std::endl;
		std::cerr << "Rest string is '";
		while(*begin){
			std::cerr << *begin++;
		}
		std::cerr<<"'"<<std::endl;
		throw ParseError();
	}
}

int main(void){
	int N;
	std::cin >> N;
	std::cin.ignore();
	while(N--){
		std::string s;
		std::getline(std::cin, s);
		State begin = s.begin();
		int ans = expression(begin);
		consume(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 == '('){
		consume(begin,'(');
		int ret = expression(begin);
		consume(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;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

/*
<四則演算の式> ::= <乗算除算の式> (+ or -) <乗算除算の式> (+ or -) ...
<乗算除算の式> ::= <括弧か数> (* or /) <括弧か数> (* or /) ...
<括弧か数>     ::= '(' <四則演算の式> ')' or <数>
<数>           ::= ...
*/

// 構文解析
using State = string::const_iterator;
class ParseError{};

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

// 数字の列をパースして，その数を返す
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);

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

    return ret;
}

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


// 四則演算の式をパースして，その評価結果を返す
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;
}

void consume(State &begin, char expected) {
    if (*begin == expected) {
        begin++;
    }
    else {
        cerr << "Expected " << expected << " but got " << *begin << endl;
        cerr << "Rest string is ";
        while (*begin) {
            cerr << *begin++;
        }
        cerr << endl;
        throw ParseError();
    }
}

int main() {
    int N;
    cin >> N;
    cin.ignore();
    rep(i, N) {
        string s;
        getline(cin, s);

        State begin = s.begin();
        int ans = expression(begin);
        //consume(begin, '=');
        cout << ans << endl;
    }
    return 0;
}

C++: #include<string>
#include<stack>
#include<cstdlib>
#include<iostream>
using namespace std;

const int obracket	=-1;
const int sum		=0;
const int diff		=1;
const int multi		=2;
const int divide	=3;

stack<double> operands;
stack<int> operators;

int evaluate(string& expression);
int calc(int a,int b,int op);

int main()
{
	string str;
	int i,n;

	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>str;
		cout<<evaluate(str)<<endl;
	}
	return 0;
}

int evaluate(string& expression)
{
	int i,n,numstart;
	bool innum=false;
	int a,b;
	char temp;

	while(!operands.empty())operands.pop();
	while(!operators.empty())operators.pop();

	for(i=0;expression[i]!='=';i++)
	{
		temp=expression[i];
		if(isdigit(temp)||temp=='.')
		{
			if(!innum)
			{
				innum=true;
				numstart=i;
			}
		}
		else
		{
			if(innum)
			{
				innum=false;
				operands.push(atof(expression.substr(numstart,i-numstart).c_str()));
			}
			switch(temp)
			{
				case '(':
					operators.push(obracket);
					break;
				case ')':
					while(operators.top()!=obracket)
					{
						b=operands.top();
						operands.pop();
						a=operands.top();
						operands.pop();
						operands.push(calc(a,b,operators.top()));
						operators.pop();
					}
					operators.pop();
					break;
				case '+':
					while(!operators.empty() && operators.top()!=obracket)
					{
						b=operands.top();
						operands.pop();
						a=operands.top();
						operands.pop();
						operands.push(calc(a,b,operators.top()));
						operators.pop();
					}
					operators.push(sum);
					break;
				case '-':
					if(i==0||expression.at(i-1)=='(')
					{
						operands.push(0);
					}
					else
					{
						while(!operators.empty() && operators.top()!=obracket)
						{
							b=operands.top();
							operands.pop();
							a=operands.top();
							operands.pop();
							operands.push(calc(a,b,operators.top()));
							operators.pop();
						}
					}
					operators.push(diff);
					break;
				case '*':
					while(!operators.empty() && operators.top()>=multi)
					{
						b=operands.top();
						operands.pop();
						a=operands.top();
						operands.pop();
						operands.push(calc(a,b,operators.top()));
						operators.pop();
					}
					operators.push(multi);
					break;
				case '/':
					while(!operators.empty() && operators.top()>=multi)
					{
						b=operands.top();
						operands.pop();
						a=operands.top();
						operands.pop();
						operands.push(calc(a,b,operators.top()));
						operators.pop();
					}
					operators.push(divide);
					break;
			}
		}
	}
	if(innum)operands.push(atof(expression.substr(numstart,i-numstart).c_str()));
	while(!operators.empty())
	{
		b=operands.top();
		operands.pop();
		a=operands.top();
		operands.pop();
		operands.push(calc(a,b,operators.top()));
		operators.pop();
	}
	return operands.top();
}

int calc(int a,int b,int op)
{
	switch(op)
	{
		case sum:
			return a+b;
			break;
		case diff:
			return a-b;
			break;
		case multi:
			return a*b;
			break;
		case divide:
			return a/b;
			break;
		default:
			return 0;
			break;
	}
}