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 <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

struct RevPolElement
{
	RevPolElement(int type, int n) : type(type), n(n) { }
	int type;
	int n;
};

deque<RevPolElement> make_revpol(char* s)
{
	map<char, int> pr;
	pr['w'] = -1;
	pr['('] = 0;

	pr['+'] = pr['-'] = 1;
	pr['*'] = pr['/'] = 2;
	pr['@'] = 3;

	char* before_unary = "+-*/(";

	deque<RevPolElement> res;
	stack<char> t;
	t.push('w');
	for (int i = 0; s[i] != '='; ++i)
	{
		if (isdigit(s[i]))
		{
			int t = s[i] - '0';
			while (isdigit(s[i+1]))
				t = t*10 + s[++i] - '0';

			res.push_back(RevPolElement(0, t));
		}
		else
		{
			char op = s[i];
			if (op == '-' && (i == 0 || strchr(before_unary, s[i-1])))
				op = '@';

			if (op == ')')
			{
				while (true)
				{
					char topOp = t.top();
					t.pop();
					if (topOp == '(')
						break;
					res.push_back(RevPolElement(1, topOp));
				}
			}
			else if (op == '(')
				t.push(op);
			else
			{
				while (pr[op] <= pr[t.top()])
				{
					res.push_back(RevPolElement(1, t.top()));
					t.pop();
				}
				t.push(op);
			}
		}
	}
	while (t.size() > 1)
	{
		res.push_back(RevPolElement(1, t.top()));
		t.pop();
	}

	return res;
}

int calculate_revpol(deque<RevPolElement> revpol)
{
	stack<int> t;
	while (!revpol.empty())
	{
		if (revpol.front().type)
		{
			char op = revpol.front().n;
			int res;
			if (op == '@')
			{
				res = -t.top();
				t.pop();
			}
			else
			{
				int a, b;
				b = t.top(); t.pop();
				a = t.top(); t.pop();
				if (op == '+')
					res = a + b;
				else if (op == '-')
					res = a - b;
				else if (op == '*')
					res = a * b;
				else if (op == '/')
					res = a / b;
			}

			t.push(res);
		}
		else
			t.push(revpol.front().n);

		revpol.pop_front();
	}

	return t.top();
}

int main()
{
	int n;
	while (cin >> n)
	{
		cin.get();
		while (n--)
		{
			char buf[256];
			cin.getline(buf, sizeof(buf));
			printf("%d\n", calculate_revpol(make_revpol(buf)));
		}
	}

	return 0;
}

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

#define rep(i,n) for (int i = 0; i < int(n); i++)
//typedef long long ll;
typedef int ll;

int it, n;
string input;

ll expr();
ll term();
ll fact();

ll expr() {
    int v = term();
    while (input[it] == '+' || input[it] == '-') {
        if (input[it++] == '+') {
            v += term();
        } else {
            v -= term();
        }
    }
    return v;
}

ll term() {
    int v = fact();
    while (input[it] == '*' || input[it] == '/') {
        if (input[it++] == '*') {
            v *= term();
        } else {
            v = (int)trunc(1.0*v/term());
            //v /= term();
        }
    }
    return v;
}

ll fact() {
    int v = 0;
    if (input[it] == '(') {
        ++it; // '('
        v = expr();
        ++it; // ')'
    } else {
        int sign = input[it] == '-' ? ++it, -1 : 1;
        while ('0' <= input[it] && input[it] <= '9') {
            v = 10*v + input[it]-'0';
            ++it;
        }
        v *= sign;
    }
    return v;
}

int main() {
    cin >> n;
    rep (i,n) {
        cin >> input;
        it = 0;
        cout << expr() << endl;
    }
}

C++: #include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	LOOP(N){
		string S=in<string>();
		vector<string> TA;
		stack<int> IP;
		stack<string> SIP;

		int M=S.size();
		string buf;
		S.insert(0,"(");
		S.insert(M,")");
		REP(i,M+1){
			char ch=S[i];
			if(ch!='+' && ch!='-' && ch!='*' && ch!='/' && ch!='(' && ch!=')'){
				buf.push_back(ch);
			}
			else if(ch!='('){
				if(!buf.empty()) TA.push_back(buf);
				buf.clear();
				if(ch=='+' || ch=='-'){
					while(!SIP.empty()){
						if(SIP.top()=="("){
							break;
						}
						TA.push_back(SIP.top());
						SIP.pop();
					}
					SIP.push(string(1,ch));
				}
				else if(ch=='*' || ch=='/'){
					if(!SIP.empty() && (SIP.top()=="*" || SIP.top()=="/")){
						TA.push_back(SIP.top());
						SIP.pop();
					}
					SIP.push(string(1,ch));
				}
				else if(ch==')'){
					while(!SIP.empty()){
						if(SIP.top()=="("){
							SIP.pop();
							break;
						}
						TA.push_back(SIP.top());
						SIP.pop();
					}
				}
			}
			else if(ch=='('){
				SIP.push("(");
			}
		}
		if(!buf.empty()) TA.push_back(buf);
		while(!SIP.empty()){
			TA.push_back(SIP.top());
			SIP.pop();
		}
		for(auto& x:TA){
			if(x!="+" && x!="-" && x!="*" && x!="/"){
				int V;
				sscanf(x.c_str(),"%d",&V);
				IP.push(V);
			}
			else if(x=="+"){
				int V=IP.top();IP.pop();
				int U=IP.top();IP.pop();
				IP.push(V+U);
			}
			else if(x=="*"){
				int V=IP.top();IP.pop();
				int U=IP.top();IP.pop();
				IP.push(V*U);
			}
			else if(x=="-"){
				int V=IP.top();IP.pop();
				int U=IP.top();IP.pop();
				IP.push(U-V);
			}
			else if(x=="/"){
				int V=IP.top();IP.pop();
				int U=IP.top();IP.pop();
				IP.push(U/V);
			}
		}
		out(IP.top());
	}
	return 0;
}