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 <string>
#include <stack>
using namespace std;

int op_priority(char a) {
	if(a == '+' || a == '-')
		return 0;
	if(a == '*')
		return 1;
	if(a == '/')
		return 2;
	return -1;
}

void clac_once(stack<int> & num_stack, stack<char> & op_stack) {
	int a, b;
	int c;
	char op;

	b = num_stack.top();
	num_stack.pop();
	a = num_stack.top();
	num_stack.pop();
	op = op_stack.top();
	op_stack.pop();

	switch(op) {
		case '+' :
			c = a + b;
			break;
		case '-':
			c = a - b;
			break;
		case '*':
			c = a * b;
			break;
		case '/':
			c = a / b;
	}

	num_stack.push(c);
}

int clac(string str) {
	stack<int> num_stack;
	stack<char> op_stack;

	for(int i = 0; i < str.size();) {
		if(str[i] == '(') {
			int start = ++i;
			int count = 1;

			while(count) {
				if(str[i] == ')')
					count--;
				else if(str[i] == '(')
					count++;
				i++;
			}

			num_stack.push(clac(string(str.begin() + start, str.begin() + i)));
		}
		else if(str[i] == '+' || str[i] == '*' || str[i] == '/' || str[i] == '=' || str[i] == ')') {
			while(!op_stack.empty() && op_priority(op_stack.top()) >= op_priority(str[i])) {
				clac_once(num_stack, op_stack);
			}
			op_stack.push(str[i]);
			i++;
		}
		else if('0' <= str[i] && str[i] <= '9') {
			int tmp = 0;
			while('0' <= str[i] && str[i] <= '9') {
				tmp *= 10;
				tmp += str[i] - '0';
				i++;
			}
			num_stack.push(tmp);
		}
		else if(str[i] == '-') {
			int tmp = 0;
			i++;
			while('0' <= str[i] && str[i] <= '9') {
				tmp *= 10;
				tmp += str[i] - '0';
				i++;
			}
			num_stack.push(tmp * -1);
			while(!op_stack.empty() && op_priority(op_stack.top()) >= op_priority('+')) {
				clac_once(num_stack, op_stack);
			}
			op_stack.push('+');
		}
	}

	return num_stack.top();
}

int main() {
	int n;

	cin >> n;
	for(int i = 0; i < n; i++) {
		string str;

		cin >> str;
		cout << clac(str) << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef long long Int;
typedef string::const_iterator Iter;

Int eval(const string&);
Int expr(Iter&);
Int term(Iter&);
Int factor(Iter&);
Int number(Iter&);

Int eval(const string &s){
	Iter it = s.begin();
	return expr(it);
}

Int expr(Iter &it){
	Int res = term(it);
	while (true){
		if (*it == '+'){
			++it;
			res += term(it);
		}
		else if (*it == '-'){
			++it;
			res -= term(it);
		}
		else return res;
	}
}

Int term(Iter &it){
	Int res = factor(it);
	while (true){
		if (*it == '*'){
			++it;
			res *= term(it);
		}
		else if (*it == '/'){
			++it;
			res /= term(it);
		}
		else return res;
	}
}

Int factor(Iter &it){
	if (*it == '('){
		++it;
		Int res = expr(it);
		++it;
		return res;
	}
	else return number(it);
}

Int number(Iter &it){
	Int res = 0;
	while (isdigit(*it)){
		res = res * 10 + (*it - '0');
		++it;
	}
	return res;
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		string s;
		cin >> s;
		s.resize(s.size() - 1);
		cout << eval(s) << endl;
	}
}

C++: n=gets.to_i;n.times{puts eval gets.strip[0..-2]}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cctype>
using namespace std;
#define P pair<int, const char*>
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)

P fact(const char *p);
P term(const char *p);
P expr(const char *p);

int main(){
    int c; cin >>c;
    REP(i, c){
        string str; cin >>str;
        cout <<expr(str.substr(0, str.size()).c_str()).first <<endl;
    }
    return 0;
}

P fact(const char *p){
    if(isdigit(*p)){
        int t = *(p++) - '0';
        while(isdigit(*p)) t = t * 10 + *(p++) - '0';
        return P(t, p);
    } else if(*p == '('){
        P r = expr(p + 1);
        if(*r.second != ')') exit(0);
        return P(r.first, r.second + 1);
    } else{
        exit(0);
    }
}


P term(const char *p){
    P r = fact(p);
    while(*r.second == '*' || *r.second == '/'){
        char op = *r.second;
        int tmp = r.first;
        r = fact(r.second + 1);
        if(op == '*') r.first = tmp * r.first;
        else r.first = tmp / r.first;
    }
    return r;
}

P expr(const char *p){
    P r = term(p);
    while(*r.second == '+' || *r.second == '-'){
        char op = *r.second;
        int tmp = r.first;
        r = term(r.second + 1);
        if(op == '+') r.first = tmp + r.first;
        else r.first = tmp - r.first;
    }
    return r;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
#include<cstdio>
#include<queue>
#include<cctype>
#include<math.h>

using namespace std;

string S;
size_t cur = 0;

int digit(){
	assert(isdigit(S[cur]));
	int n = S[cur] - '0';
	cur = cur + 1;
	return n;
}

int number(){
	int n = digit();
	while (cur < S.size() && isdigit(S[cur]))
		n = n * 10 + digit();
	return n;
}

int expression();
int factor(){
	if (S[cur] != '(') return number();
	cur += 1;
	int n = expression();
	assert(S[cur] == ')');
	cur += 1;
	return n;
}

int term(){
	int a = number();
	while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')){
		char op = S[cur++];
		int b = number();
		if (op == '*') a *= b; else a /= b;
	}
	return a;
}

int expression(){
	int a = term();
	while (cur < S.size() && (S[cur] == '+' || S[cur] == '-')){
		char op = S[cur++];
		int b = number();
		if (op == '+') a += b; else a -= b;
	}
	return a;
}

int parse(){
	return expression();
}

int main(){
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++){
		cur = 0;
		scanf("%s", &S);
		S.resize(S.size() - 1);
		cout << parse() << endl;
	}
	return 0;
}