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 <iostream>
#include <string>
#include <cctype>

using namespace std;
typedef string::const_iterator State;

class ParseError{};

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

// 四則演算の式をパースして，その評価結果を返す．
int expression(State &begin) {
	int ret = term(begin);
	
	while (true) {
		if (*begin == '+') {
			begin++;
			ret += term(begin);
		} else if (*begin == '-') {
			begin++;
			ret -= term(begin);
		} else {
			break;
		}
	}
	
	return ret;
}

// 乗算除算の式をパースして，その評価結果を返す．
int term(State &begin) {
	int ret = number(begin);
	
	while (true) {
		if (*begin == '*') {
			begin++;
			//ret *= number(begin);
			ret *= factor(begin); // 括弧がある式に対応
		} else if (*begin == '/') {
			begin++;
			//ret /= number(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 number(State &begin) {
	int ret = 0;
	
	while (isdigit(*begin)) {
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	
	return ret;
}

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

C++: #include <iostream>
#include <cassert>
#include <cctype>
using namespace std;
string S;
size_t cur;
int expression();

int digit() {
    //  Digit := '0' | '1' | ... | '9'
    assert(isdigit(S[cur]));    // S[cur] が数字であることを確認
    int n = S[cur] - '0';       // '0' を 0 に変換
    cur = cur + 1;              // 一文字進める
    return n;
}

int number() {
    //  Number := Digit の繰り返し
    int n = digit();
    while (cur < S.size() && isdigit(S[cur])) {     // 次も数字が 1 文字先読み
        n = n * 10 + digit();
    }
    return n;
}

int factor() {
    //  Factor := '(' Expression ')' | Number
    if (S[cur] != '(') return number();
    cur += 1;
    int n = expression();
    assert(S[cur] == ')');
    cur += 1;
    return n;
}

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

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

int parse() { return expression(); }

int main() {
    int n; cin >> n;
    while (n--) {
        cin >> S;
        cur = 0;
        S.resize(S.size() - 1);     // 最後の = を無視
        cout << expression() << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
vector<char> buf;
stack<char> tmp;
char t;
void add_buf(char x)
{
	buf.pb(x);
	return;
}
void add_tmp(char x)
{
	tmp.push(x);
	return;
}
void move()
{
	char x=tmp.top();
	tmp.pop();
	buf.pb(x);
	return;
}
void reset()
{
	while(1)
	{
		char x=tmp.top();
		if(x=='(')
		{
			tmp.pop();
			break;
		}
		buf.pb(x);
		tmp.pop();
	}
	return;
}
int priority(char x)
{
	if(x=='+'||x=='-')return 0;
	if(x=='*'||x=='/')return 1;
	if(x==')')return 2;
	if(x=='(')return 3;
	return 4;
}
void end()
{
	while(!tmp.empty())
	{
		char x=tmp.top();
		tmp.pop();
		buf.pb(x);
	}
	return;
}
bool is_num(char x)
{
	return priority(x)==4;
}
int calc()
{
	stack<char> c;
	for(int i=0;i<buf.size();i++)
	{
		if(is_num(buf[i]))
		{
			c.push(buf[i]-'0');
		}
		else
		{
			int a=c.top();
			c.pop();
			int b=c.top();
			c.pop();
			cout << a << ' '<< b << endl;
			switch(buf[i])
			{
				case '+':c.push(b+a);break;
				case '-':c.push(b-a);break;
				case '*':c.push(a*b);break;
				case '/':c.push(b/a);break;
			}
		}
	}
	return c.top();
}
int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		buf.clear();
		while(!tmp.empty())
		{
			tmp.pop();
		}
		char s[101];
		scanf("%s",s);
		for(int i=0;i<strlen(s)-1;i++)
		{
			if(is_num(s[i]))
			{
				add_buf(s[i]);
				continue;
			}
			if(priority(s[i])==2)
			{
				reset();
				continue;
			}
			if(priority(s[i])==3)
			{
				add_tmp(s[i]);
				continue;
			}
			while(!tmp.empty())
			{
				if(priority(tmp.top())==1&&priority(s[i])==0)
				{
					move();
				}
				else break;
			}
			add_tmp(s[i]);
		}
		end();
		for(int i=0;i<buf.size();i++)
		{
			cout << buf[i] << ' ';
		}
		cout << endl;
		cout << calc() << endl;
	}
	return 0;
}

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;
			if(('0' <= str[i - 1] && str[i - 1] <= '9') || !i)
				op_stack.push('+');
			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(str[i])){
				clac_once(num_stack, op_stack);
			}
			op_stack.push(str[i]);
			i++;
		}
	}

	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;
}