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<cassert>
#include<cctype>
using namespace std;

string s;
int cur=0;

char readchar()
{
    assert(cur<s.size());
    char ret=s[cur];
    cur+=1;
    return ret;
}

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()
{
    int n,a;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> s;
        cur=0;
        a=parse();
        cout << a << endl;
    }
}

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

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 == '*') {
			ret *= term(++begin);
		}
		else if (*begin == '/') {
			ret /= term(++begin);
		}
		else break;
	}
	return ret;
}


int expression(State &begin) {
	int ret = term(begin);
	for (;;) {
		if (*begin == '+') {
			ret += term(++begin);
		}
		else if (*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(str.begin()) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double EPS = 1e-10;

typedef string::const_iterator State;

int express(State& p);
int factor(State& p);
int term(State &p);
int number(State &p);

// 足し算
int express(State& p) {
	int r = factor(p);
	
	for(;;) {
		if(*p == '+') {
			p++;
			int rs = factor(p);
			r += rs;
		}
		else if(*p == '-') {
			p++;
			int rs = factor(p);
			r -= rs;
		}
		else {
			break;
		}
	}
	
	return r;
}

// カッコ
int factor(State &p) {
	if(*p == '(') {
		p++;
		int ret = express(p);
		p++;
		return ret;
	}
	return term(p);
}

// 掛け算
int term(State &p) {
	int r = number(p);
	
	for(;;) {
		if(*p == '*') {
			p++;
			int rs = number(p);
			r *= rs;
		}
		else if(*p == '/') {
			p++;
			int rs = number(p);
			r /= rs;
		}
		else {
			break;
		}
	}
	
	return r;
}

int number(State &p) {
	if(*p == '(') return factor(p);
	int ret = 0;
	
	while(isdigit(*p)) {
		ret *= 10;
		ret += *p - '0';;
		p++;
	}
	
	return ret;
}

int main() {
	int N; cin >> N;
	cin.ignore();
	while(N--) {
		string line;
		getline(cin, line);
		State p = line.begin();
		int ans = express(p);
		cout << ans << endl;
	}
	return 0;
}

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

double calc2(char *eq){
	long c=0, sign[100]={0};
	double num[100]={0};
	char *p = eq;
	while(*p){
		if('0'<=*p && *p<='9') num[c]=num[c]*10+*p-'0';
		else{
			if(*p=='+') sign[c]=1;
			else if(*p=='-') sign[c]=2;
			else if(*p=='*') sign[c]=3;
			else if(*p=='/') sign[c]=4;
			else if(*p=='=') break;
			else printf("err %c\n", *p);
			c++;
		}
		p++;
	}
	c++;
	for(int i=0;i<c-1;i++){
		if(sign[i]==3 || sign[i]==4){
			if(sign[i]==3)	num[i+1] = num[i] * num[i+1];
			if(sign[i]==4)	num[i+1] = num[i] / num[i+1];
			for(long j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	for(int i=0;i<c-1;i++){
		if(sign[i]==1 || sign[i]==2){
			if(sign[i]==1)	num[i+1] = num[i] + num[i+1];
			if(sign[i]==2)	num[i+1] = num[i] - num[i+1];
			for(long j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	return num[0];
}

long calc(char *eq){
	char *p, *p2, buf[120]={0}, cp[120]={0};
	long k,ret;
	strcpy(cp, eq);
	while((p=strchr(cp, '('))!=NULL){
		for(k=0,p2=p+1;;p2++)
			if(*p2=='(')k++;
			else if(*p2==')'){
				if(k)k--;
				else break;
			}
		memcpy(buf, p+1, p2-p-1);
		buf[p2-p-1]='=';
		ret = calc(buf);
		*p=0;
		sprintf(buf, "%s%ld%s", cp, ret, p2+1);
		strcpy(cp,buf);
	}
	return (long)calc2(cp);
}

int main(){
	long i,j,n;
	char buf[120], p;
	for(cin >> n;n;n--){
		cin >> buf;
		cout << calc(buf) <<endl;
	}
	return 0;
}