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 <cstdio>
#include <string> 
#include <algorithm>
#include <iostream>
using namespace std;
typedef string::iterator State;
bool isdigit(State& pos);
int number(State& pos);
int factor(State& pos);
int expression(State& pos);
int term(State& pos);

bool isdigit(State& pos)
{
	if('0'<=*pos&&*pos<='9')return true;
	else return false;
}
int number(State& pos)
{
	int res = 0;
	while(isdigit(pos))
	{
		res*=10;
		res += (*pos)-'0';
		pos++;
	}
	return res;
}
int term(State& pos)
{
	int ret = factor(pos);
	while(*pos == '*'||*pos == '/')
	{
		bool mul = (*pos == '*');
		pos++;
		int k = factor(pos);
		if(mul)ret *= k;
		else ret/=k;
	}
	return ret;
}
int factor(State& pos)
{
	int ret;
	if(*pos=='(')
	{
		pos++;
		ret = expression(pos);
		pos++;
	}
	else ret = number(pos);
	return ret;
}
int expression(State& pos)
{
	int ret = term(pos);
	while(*pos == '+'||*pos == '-')
	{
		bool plus = (*pos == '+');
		pos++;
		int k = term(pos);
		if(plus)ret += k;
		else ret -= k;
	}
	return ret;
}
int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		string s;
		cin >> s;
		State pos = s.begin();
		cout << expression(pos) << endl;
	}
	return 0;
}

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

long 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 (int)num[0];
}

long calc(char *eq){
	char *p, *p2, buf[120]={0}, cp[120]={0};
	long k,ret;
	strcpy(cp, eq);
	if((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 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;
}

C++: 
#include <iostream>
#include <string>
#include <cctype>
#include <stdlib.h>

using namespace std;

string ex_s; //expression_string
int n;

int cal(string ex_s) //calculate expression_string
{
    int i;
    int j;
    int ans; //answer
    int cnt_p=0; //count_parentheses
    int cnt_pp=1;
    int cnt_as=0; //count_add subtract
    int cnt_md=0; //count_nultiply divide
    for(i=0;i<ex_s.size();i++)
    {
        if(ex_s[i]=='(')
        {
            for(j=i+1;j<ex_s.size();j++)
            {
                if(ex_s[j]=='(') cnt_pp+=1;
                else if(ex_s[j]==')')
                {
                    cnt_pp-=1;
                    if(cnt_pp==0)
                    {
                        cnt_pp=1;
                        break;
                    }
                }
            }
            ans=cal(ex_s.substr(i+1,j-i-1));
            ex_s=ex_s.substr(0,i)+to_string(ans)+ex_s.substr(j+1);
            i=j;
            cnt_p+=1;
        }
    }
    if(cnt_p!=0)
    {
        return cal(ex_s);
    }
    else
    {   for(i=0;i<ex_s.size();i++)
        {
            if(ex_s[i]=='+')
            {
                ans=cal(ex_s.substr(0,i))+cal(ex_s.substr(i+1));
                cnt_as+=1;
                return ans;
                break;
            }
            else if(ex_s[i]=='-')
            {
                if(i==0) ans=0-cal(ex_s.substr(i+1));
                else ans=cal(ex_s.substr(0,i))-cal(ex_s.substr(i+1));
                cnt_as+=1;
                return ans;
                break;
            }
        }
        if(cnt_as==0)
        {
            for(i=0;i<ex_s.size();i++)
            {
                if(ex_s[i]=='*')
                {
                    ans=cal(ex_s.substr(0,i))*cal(ex_s.substr(i+1));
                    cnt_md+=1;
                    return ans;
                    break;
                }
                else if(ex_s[i]=='/')
                {
                    ans=cal(ex_s.substr(0,i))/cal(ex_s.substr(i+1));
                    cnt_md+=1;
                    return ans;
                    break;
                }
            }
            if(cnt_md==0)
            {
                return atoi(ex_s.c_str());
            }
        }
    }
}

int main()
{
    cin >> n;
    while(n--)
    {
        cin >> ex_s;
        ex_s.pop_back();
        cout << cal(ex_s) << endl;
    }
	return 0;
}