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 <stack>
#include <map>
#include <cstdlib>
#include <cctype>
#include <cstdio>
#include <cstring>

using namespace std;

int str2arr(char s[], string A[]) {
    bool flag = true;
    string t;
    int l = strlen(s);
    int n = 0;
    for (i = 0; i < l; i++) {
        if (isdigit(s[i]) && flag) {
            t = "";
            int j = 0;
            while (isdigit(s[i+j])) {
                t += s[i+j];
                if (i+j == l-1)
                    break;
                j++;
            }
            A[n++] = t;
            flag = false;
        }
        else if (!isdigit(s[i])) {
            A[n++] = s[i];
            flag = true;
        }
    }
    return n;
}

int Generate_RPN(int n, string A[], string B[]) {
    map<string, int> table;
    table["*"] = 1;
    table["/"] = 1;
    table["+"] = 0;
    table["-"] = 0;
    table["("] = -1;
    table[")"] = -1;
    stack<string> S;
    int j = 0;

    for (int i = 0; i < n; i++) {
        if (isdigit(A[i][0])) {
            B[j++] = A[i];
        }

        else if (A[i] == "(")
            S.push(A[i]);

        else if (A[i] == ")") {
            while (S.top() != "(") {
                B[j++] = S.top();
                S.pop();
            }
            S.pop();
        }
        else {
            while ((!S.empty()) && (table[S.top()] >= table[A[i]])) {
                B[j++] = S.top();
                S.pop();
            }
            S.push(A[i]);
        }
    }
    while (!S.empty()) {
        B[j++] = S.top();
        S.pop();
    }
    return j;
}

void calculate(int n, string s[]) {
    stack<double> St;
    double a, b;

    for (int i = 0; i < n; i++) {
        if (s[i] == "+") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a+b);
        }
        else if (s[i] == "-") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a-b);
        }
        else if (s[i] == "*") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a*b);
        }
        else if (s[i] == "/") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a/b);
        }
        else {
            St.push(atoi(s[i].c_str()));
        }
    }
    cout << int(St.top()) << endl;
}

int main()
{
    int n, l, t;
    string A[101], B[101];
    char s[101];

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        s[0] = '\0';
        scanf("%s", s);
        s[strlen(s)-1] = '\0';

        l = str2arr(s, A);
        t = Generate_RPN(l, A, B);

        calculate(t, B);
    }

    return 0;
}

C++: #include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<sstream>

std::string a;
std::vector<std::string>v;
std::vector<std::string>va;
std::stack<std::string>s;
int i=0;

void bun(){
	int ii=0,k=0;
	for(int jj=0;jj<a.size();jj++){
		if(a[jj]=='+'||a[jj]=='-'||a[jj]=='*'||a[jj]=='/'||a[jj]==')'){
			if(a[jj-1]!=')'){
				v.push_back("1");
				std::stringstream z;
				z<<a.substr(ii,jj-ii);
				z>>v[k];
				k++;
				ii=jj+1;
			}
			v.push_back("1");
			v[k]=a[jj];
			k++;
		}else if(a[jj]=='('){
			v.push_back("1");
			v[k]=a[jj];
			k++;
			ii=jj+1;
		}else if(jj==a.size()-1){
			v.push_back("1");
			jj++;
			std::stringstream z;
			z<<a.substr(ii,jj-ii);
			z>>v[k];
		}
	}
}

std::string change(double p){
	std::stringstream z;
	std::string str;
	z<<p;
	z>>str;
	return str;
}

void por(int p,int q,int si){
	int m=0,ma=0;
	for(int k=p;k<=q;k++){
		if(v[k]==")"){}
		else if(v[k]=="("){
			int ky,z=1;
			for(ky=k+1;ky<=q;ky++){
				if(v[ky]=="(")z++;
				if(v[ky]==")")z--;
				if(z==0)break;
			}
			por(k+1,ky-1,s.size());
			k=ky;
		}else if(v[k]!="+"&&v[k]!="-"&&v[k]!="*"&&v[k]!="/"){
			va.push_back("1");
			va[i]=v[k];
			i++;
		}else if(v[k]=="+"||v[k]=="-"||v[k]=="*"||v[k]=="/"){
			if(v[k]=="+")ma=1;
			if(v[k]=="-")ma=1;
			if(v[k]=="*")ma=2;
			if(v[k]=="/")ma=3;
			while(ma<=m&&s.size()>si){
				va.push_back("1");
				va[i]=s.top();
				s.pop();
				i++;
				if(s.size()>=1){
					if(s.top()=="+")m=1;
					if(s.top()=="-")m=1;
					if(s.top()=="*")m=2;
					if(s.top()=="/")m=3;
				}else break;
			}
			s.push(v[k]);
			m=ma;
		}if(k==q){
			while(s.size()>si){
				va.push_back("1");
				va[i]=s.top();
				s.pop();
				i++;
			}
		}
	}
}

std::string calc(){
	std::stack<std::string>sa;
	for(int k=0;k<va.size();k++){
		if(va[k]!="+"&&va[k]!="-"&&va[k]!="*"&&va[k]!="/")sa.push(va[k]);
		else{
			std::stringstream z;
			std::stringstream zz;
			double x,y;
			z<<sa.top();
			z>>x;
			sa.pop();
			zz<<sa.top();
			zz>>y;
			sa.pop();
			if(va[k]=="+")sa.push(change(y+x));
			if(va[k]=="-")sa.push(change(y-x));
			if(va[k]=="*")sa.push(change(y*x));
			if(va[k]=="/")sa.push(change(y/x));
		}
	}
	return sa.top();
}

int main(){
	std::stringstream z;
	double ans;
	std::cin>>a;
	a.erase(a.size(),1);
	bun();
	por(0,v.size()-1,0);
	z<<calc();
	z>>ans;
	std::cout<<ans<<std::endl;
	return 0;
}

C++: 
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#include <cmath>
#include <cassert>
#define INF 10000000000
#define MOD 10000000007
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef pair<int, int> i_i;

string S;
size_t cur = 0;

//with ()*************************************************************************************

int factor();

bool isdigit(char a){
    if (a == '0' or a == '1' or a == '2' or a == '3' or a == '4' or a == '5' or a == '6' or a == '7' or a == '8' or a == '9') {
        return true;
    }
    return false;
}

//********************************************************************************************

int digit(){
    int n = S[cur] - '0';
    cur++;
    return n;
}

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

int term(){
    //*****************************************************************************************
    int a = factor();
    //*****************************************************************************************
    //int a = number();
    while (cur < S.size() and (S[cur]=='*' or S[cur]=='/')) {
        char op = S[cur++];
        //int b = number();
        //*****************************************************************************************
        int b = factor();
        //*****************************************************************************************
        if(op=='*')a *= b; else a/=b;
    }
    return a;
}

int expression(){
    int a = term();
    while (cur < S.size() and (S[cur] == '+' or S[cur] == '-')) {
        char op = S[cur++];
        int b = term();
        if(op == '+') a += b; else a -= b;
    }
    return a;
}

//with() *************************************************************************************
int factor(){
    if(S[cur] != '(') return number();
    cur++;
    int n = expression();
    assert(S[cur] == ')');
    cur++;
    return n;
}
//********************************************************************************************

int main(){
    int n;
    cin >> n;
    while(n-- > 0){
        cur = 0;
        cin >> S;
        S.resize(S.length()-1);
        cout << expression()<<endl;
    }
}