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 <cstdio>
#include <vector>
#include <string>
#include <deque>
#include <memory.h>

#define rep(idx, max)			for(int idx = 0, idx##Max = (max); idx < idx##Max; idx ++)
#define rrep(idx, min, max)	for(int idx = (min), idx##Max = max; idx < idx##Max; idx ++)
#define erep(idx, min, max)	for(int idx = (min), idx##Max = max; idx <= idx##Max; idx ++)

#define rev(idx, max)			for(int idx = (max) - 1; idx >= 0; idx --)
#define rrev(idx, min, max)	for(int idx = (max) - 1, idx##Min = (min); idx >= idx##Min; idx --)
#define erev(idx, min, max)	for(int idx = (max), idx##Min = (min); idx >= idx##Min; idx --)

#define foreach(it, obj)	for(auto it = obj.begin(), it##End = obj.end(); it >= it##End; it ++)

using namespace	std;

class CCalc
{
	string	s_;
	int	pos_;
	
	int	IsDigit(int x)	{	return(x <= '9' && x >= '0');	}
	void	SkipSpace()
	{
		cout << "Skipping...";
		for(int c = s_[pos_]; (c == ' ' || c == '\t') && pos_ < s_.size(); pos_ ++);
		cout << "OK" << endl;
	}
	int	Number()
	{
		int num = 0;
		while(IsDigit(s_[pos_]))	{	num	= num * 10 + s_[pos_ ++] - '0';	}
		return(num);
	}
	int	Factor()
	{
		int val;
		if(pos_ >= s_.size())	{	cout << "warning: Out of bounds!" << endl;	}
		if(IsDigit(s_[pos_]))
		{
			val = Number();
			return(val);
		}
		pos_ ++;
		val	= Expr();
		pos_ ++;
		return(val);
	}
	int	Term()
	{
		int	val1	= Factor();
		while(s_[pos_] == '*' || s_[pos_] == '/')
		{
			char	op	= s_[pos_ ++];
			int val2	= Factor();
			switch(op)
			{
				case '*':	val1 *= val2;	break;
				case '/':	val1 /= val2;	break;
			}
		}
		return(val1);
	}
	int	Expr()
	{
		int	val1	= Term();
		while(s_[pos_] == '+' || s_[pos_] == '-')
		{
			char	op	= s_[pos_ ++];
			int val2	= Term();
			switch(op)
			{
				case '+':	val1 += val2;	break;
				case '-':	val1 -= val2;	break;
			}
		}
		return(val1);
	}
	
public:
	int	Eval(string &expression)
	{
		pos_	= 0;
		int pos = 0;
		s_.resize(expression.size());
		rep(i, expression.size())
		{
			if(expression[i] != ' ')
			{	s_[pos ++] = expression[i];	}
		}
		return(Expr());
	}
};

int main()
{
	CCalc	calc;
	string	expression;
	int tc;
	
	for(cin >> tc, cin.ignore(); tc > 0; tc --)
	{
		getline(cin, expression);
		cout << calc.Eval(expression) << endl;
	}
	
//	while(getline(cin, expression), expression.size())
//	{	::printf("%s = %d\n", expression.c_str(), calc.Eval(expression));	}
}

C++: #include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <climits>
#include <cmath>
#include <cassert>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define ll long long
using namespace std;

string m;
int point = 0;
ll term(void);

bool left() {
    if(point < m.size()) return true;
    else return false;
}

char peek() {
    return m[point];
} 

char pop() {
    return m[point++];
}

void eat(char ch) {
    assert(left() && pop() == ch);
}

ll expr() {
    ll res = term();
    while(left() && (peek() == '+' || peek() == '-')) {
        if(peek() == '+') {
            eat('+');
            res += term();
        } else {
            eat('-');
            res -= term();
        }
    }
    return res;
}

ll number() {
    ll res = 0;
    while(left() && isdigit(peek())) {
        res *= 10;
        res += pop() - '0';
    }
    return res;
}

ll factor() {
    if(peek() == '('){
        eat('(');
        ll res = expr();
        eat(')');
        return res;
    } else {
        return number();
    }
}

ll term() {
    ll res = factor();
    while(left() && (peek() == '*' || peek() == '/')) {
        if(peek() == '*') {
            eat('*');
            res *= factor();
        } else {
            eat('/');
            res /= factor();
        }
    }
    return res;
}

int main(void){
    int n;
    ll ans;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i,n) {
        cin >> m;
        point = 0;
        ans = expr();
        cout << ans << endl;
        eat('=');
    }
}