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 <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef vector <int> VI;
typedef vector <char> VC;

string toNums( string s ) {
    string R = "+-*/";
    for ( int i = 0; i < 4; ++ i ) {
        replace( s.begin(), s.end(), R[i], ' ' );
    }
    return s;
}

string toOps( string s ) {
    string R = "0123456789";
    for ( int i = 0; i < 10; ++ i ) {
        replace( s.begin(), s.end(), R[i], ' ' );
    }
    return s;
}

int eval( string expr ) {
    stack <int> S;
    for ( int i = 0; i < (int)expr.size(); ++ i ) {
        if ( expr[i] == '(' ) {
            S.push( i );
        } else if ( expr[i] == ')' ) {
            int left = S.top();
            int right = i;
            string L = expr.substr( 0, left );
            string M = expr.substr( left, right - left + 1 );
            string R = expr.substr( right + 1 );
            ostringstream os;
            os << eval( M.substr( 1, M.size()-2 ) );
            expr = L + os.str() + R;
            i = -1;
            S = stack <int>();
            continue;
        }
    }
    string nums = toNums( expr );
    string ops = toOps( expr );
    VI N;
    int num;
    istringstream is1( nums );
    while ( is1 >> num ) {
        N.push_back( num );
    }
    VC O;
    char op;
    istringstream is2( ops );
    while ( is2 >> op ) {
        O.push_back( op );
    }
    for ( int i = 0; i + 1 < (int)N.size(); ++ i ) {
        int a = N[i], b = N[i+1];
        char c = O[i];
        if ( c == '*' ) {
            N.erase( N.begin() + i );
            char cc = O[i+1];
            O.erase( O.begin() + i );
            N[i] = a * b;
            O[i] = cc;
            i --;
        } else if ( c == '/' ) {
            N.erase( N.begin() + i );
            char cc = O[i+1];
            O.erase( O.begin() + i );
            N[i] = a / b;
            O[i] = cc;
            i --;
        }
    }
    int answer = 0;
    if ( N.size() == O.size() ) {
        for ( int i = 0; i < (int)N.size(); ++ i ) {
            if ( O[i] == '+' ) {
                answer += N[i];
            } else {
                answer -= N[i];
            }
        }
    } else {
        answer = N[0];
        for ( int i = 0; i + 1 < (int)N.size(); ++ i ) {
            if ( O[i] == '+' ) {
                answer += N[i+1];
            } else {
                answer -= N[i+1];
            }
        }
    }
    return answer;
}

int main() {
    int n;
    while ( cin >> n ) {
        if ( n == 0 ) break;
        for ( int i = 0; i < n; ++ i ) {
            string line;
            cin >> line;
            cout << eval( line.substr( 0, line.size() - 1 ) ) << endl;
        }
    }
    return 0;
}

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

int stoi(const string& s) {
	int res;
	istringstream is(s);
	is >> res;
	return res;
}

string s;

int factor(int, int);
int term(int, int);
int formula(int, int);

int factor(int l, int r) {
	if(s[l] == '(')
		return formula(l + 1, r - 1);

	return stoi(s.substr(l, r - l));
}

int term(int l, int r) {
	int cnt = 0;
	for(int i = r - 1; i >= 0; --i) {
		if(s[i] == ')')
			++cnt;

		else if(s[i] == '(')
			--cnt;

		else if(!cnt) {
			if(s[i] == '*')
				return term(l, i) * factor(i + 1, r);

			else if(s[i] == '/')
				return term(l, i) / factor(i + 1, r);
		}
	}

	return factor(l, r);
}

int formula(int l, int r) {
	int cnt = 0;
	for(int i = r - 1; i >= 0; --i) {
		if(s[i] == ')')
			++cnt;

		else if(s[i] == '(')
			--cnt;

		else if(!cnt) {
			if(s[i] == '+')
				return formula(l, i) + term(i + 1, r);

			else if(s[i] == '-')
				return formula(l, i) - term(i + 1, r);
		}
	}

	return term(l, r);
}

int main() {
	cin.tie(false);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	for(int i = 0; i < n; ++i) {
		cin >> s;
		cout << formula(0, s.size() - 1) << endl;
	}

	return EXIT_SUCCESS;
}

C++: #include <iostream>

using namespace std;

char num[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

int exp(char a[]);
int term(char a[]);
int factor(char a[]);
int p;

bool func(char a)
{
	for(int i = 0; i < 10; i++){
		if(a == num[i]){
			return true;
		}
	}
	return false;
}

int exp(char a[])
{
	int x = term(a);
	while(a[p] == '+' || a[p] == '-'){
		if(a[p] == '+'){
			p++;
			x += term(a);
		} else {
			p++;
			x -= term(a);
		}
	}
	
	return x;
}

int term(char a[])
{
	int x = factor(a);
	while(a[p] == '*' || a[p] == '/'){
		if(a[p] == '*'){
			p++;
			x *= factor(a);
		} else {
			p++;
			x /= factor(a);
		}
	}
	
	return x;
}

int factor(char a[])
{
	while(a[p] == '(' || func(a[p])){
		if(a[p] == '('){
			p++;
			return exp(a);
		} else {
			for(int i = 0; i < 10; i++){
				if(a[p] == num[i]){
					p++;
					return i;
				}
			}
		}
	}
	
	return 0;
}

int main(int argc, char **argv)
{
	int n;
	char a[100];
	
	cin >> n;
	while(n--){
		scanf("%s", a);
		p = 0;
		cout << exp(a) << endl;
	}
	
	return 0;
}

C++: 
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <cctype>
using namespace std;

typedef string::const_iterator State;
int expression(State &begin);

typedef string::const_iterator State;
int expression(State &begin);

int number(State &begin) {
	int ret = 0;
	for (; isdigit(*begin);) {
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	return ret;
}
int factor(State &begin) {
	int ret;
	if (*begin == '(') {
		begin++;
		ret = expression(begin);
		begin++;
	}
	else {
		return number(begin);
	}
	return ret;
}
int term(State &begin) {
	int ret = factor(begin);
	for (;;) {
		if (*begin == '*') {
			begin++;
			ret *= factor(begin);
		}
		else if (*begin == '/') {
			begin++;
			ret /= factor(begin);
		}
		else break;
	}
	return ret;
}


int expression(State &begin) {
	int ret = term(begin);
	for (;;) {
		if (*begin == '+') {
			begin++;
			ret += term(begin);
		}
		else if (*begin == '-') {
			begin++;
			ret -= term(begin);
		}
		else break;
	}
	return ret;
}

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