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++: # define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <set>
# include <map>
# include <stack>
using namespace std;
# define M_PI 3.141592
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define pri_max 60000
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
bool isOperator(string c)
{
	if (c == "+" || c == "-" || c == "/" || c == "*" || c == "%" || c == "(" || c == ")" || c == "=")return true;
	return false;
}
int op_pri(string c)
{
	if (c == "+" || c == "-")return 2;
	if (c == "(")return -1;
	return 3;
}
long long calc(long long a, long long b, string op)
{
	if (op == "+")return a + b;
	if (op == "-")return a - b;
	if (op == "*")return a * b;
	if (op == "/")return a / b;
}

int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		string f; cin >> f;
		vector<string> v;
		string temp;
		for (int i = 0; i < f.size(); i++)
		{
			string now;
			now = f[i];
			if (isOperator(now))
			{
				if (temp != "")v.push_back(temp);
				v.push_back(now);
				temp = "";
			}
			else
			{
				temp += now;
			}
		}

		stack<string> st;
		vector<string> p;

		for (int i = 0; i < v.size() - 1; i++)
		{
			string now = v[i];
			if (isOperator(now))
			{
				if (now == "(")
				{
					st.push(now);
				}
				else if (now == ")")
				{
					while (st.top() != "(")
					{
						p.push_back(st.top());
						st.pop();
					}
					st.pop();
				}
				else
				{
					while (!st.empty())
					{
						if (op_pri(st.top()) >= op_pri(now))
						{
							p.push_back(st.top());
							st.pop();
						}
						else break;
					}
					st.push(now);
				}
			}
			else
			{
				p.push_back(now);
			}
		}
		while (!st.empty()) { p.push_back(st.top()); st.pop(); }

		stack<long long> a;

		for (int i = 0; i < p.size(); i++)
		{
			string now = p[i];
			if (isOperator(now))
			{
				long long v1, v2;
				v2 = a.top(); a.pop();
				v1 = a.top(); a.pop();
				a.push(calc(v1, v2, now));
			}
			else
			{
				a.push(atol(now.c_str()));
			}
		}
		cout << a.top() << endl;

	}
}

C++: #include <iostream>
#include <string>
#include <cctype>
#include <sstream>

using namespace std;

typedef string::const_iterator Cursor;
class ParseError{};

// <四則演算の式> ::= <乗算除算の式> (+ or -) <乗算除算の式> (+ or -) ...
// <乗算除算の式> ::= <括弧か数> (* or /) <括弧か数> (* or /) ...
// <括弧か数>     ::= '(' <四則演算の式> ')' or <数>
// <数>           ::= (0|1|2|3|4|5|6|7|8|9)+

int expression(Cursor&);
int term(Cursor&);
int factor(Cursor&);
int number(Cursor&);

// <四則演算の式> ::= <乗算除算の式> (+ or -) <乗算除算の式> (+ or -) ...
int expression(Cursor &c){
    int ret = term(c);
    while(*c == '+' or *c == '-'){
        if(*c == '+'){
            c++;
            ret += term(c);
        }else{
            c++;
            ret -= term(c);
        }
    }
    return ret;
}

// <乗算除算の式> ::= <括弧か数> (* or /) <括弧か数> (* or /) ...
int term(Cursor &c){
    int ret = factor(c);
    while(*c == '*' or *c == '/'){
        if(*c == '*'){
            c++;
            ret *= term(c);
        }else{
            c++;
            ret /= term(c);
        }
    }
    return ret;
}

// <括弧か数>     ::= '(' <四則演算の式> ')' or <数>
int factor(Cursor &c){
    if(*c == '('){
        c++;
        int ret = expression(c);
        // ')'
        c++;
        return ret;
    }else{
        return number(c);
    }
}

// <数>           ::= (0|1|2|3|4|5|6|7|8|9)+
int number(Cursor &c){
    stringstream ss;
    while(isdigit(*c)){
        ss << *c;
        c++;
    }
    int ret;
    ss >> ret;
    return ret;
}

int main(){
    int test_case;
    cin >> test_case;
    cin.ignore();
    for(int i=0;i<test_case;i++){
        string s;
        getline(cin,s);
        Cursor c = s.begin();
        cout << expression(c) << endl;
        if(*c != '='){
            cerr  << 'n' << endl;
        }
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <cctype>
#include <cassert>

using namespace std;

string S;
size_t cur = 0;
int N;
int parse();

char readchar(){
    assert(cur < S.size());
    return S[cur++];
}

char peek(){
    //assert(cur < S.size());
    return S[cur];
}

int digit(){
    assert(isdigit(peek())); 
    int n = readchar() - '0';
    return n;
}

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


int expression();

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

int term() {
    int a = factor();
    while (cur < S.size() && (peek() == '*' || peek() == '/')){
        char op = readchar();
        int b = factor();
        if (op == '*') a *= b; else a /= b;
    }
    return a;
}

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

int parse() { return expression(); }


int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> S;
        cur = 0;
        int a = parse();
        cout << a << endl;
    }
}