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 i, 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 l, t;
    string A[101], B[101];
    char s[101];

    scanf("%s", s);

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

    calculate(t, B);

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int exp(string&, int&);
int term(string&, int&);
int factor(string&, int&);

int exp(string& str, int& p){
  int res = term(str, p);
  while(str[p] == '+' || str[p] == '-'){
    if(str[p] == '+'){
      p++;
      res += term(str, p);
    }else{
      p++;
      res -= term(str, p);
    }
  }
  return res;
}

int term(string& str, int& p){
  int res = factor(str, p);
  while(str[p] == '*' || str[p] == '/'){
    if(str[p] == '*'){
      p++;
      res *= factor(str, p);
    }else{
      p++;
      res /= factor(str, p);
    }
  }
  return res;
}

int factor(string& str, int& p){
  int res = 0;
  int keta = 1;
  int initp = p;
  if(str[p] == '('){
    while(str[p] != ')'){
      p++;
      res = exp(str, p);
    }
    p++;
  }else{
    while(isdigit(str[p])){
      p++;
    }
    for(int i=p-1; i >= initp; i--){
      res += keta * (str[i] - '0');
      keta *= 10;
    }
  }
  return res;
}


int main(void){
  int n; cin >> n;
  while(n--){
    int p=0;
    string str;
    cin >> str;
    cout << exp(str, p) << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
char str[120];

int calc2(char *eq){
	int c=0,num[100]={0}, sign[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;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(int j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	for(int i=0;i<c;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(int j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	return num[0];
}

int calc(char *eq){
	char *p, *p2, buf[120]={0}, cp[120]={0};
	int 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%d%s", cp, ret, p2+1);
		strcpy(cp,buf);
	}
	return calc2(cp);
}

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

C++: 
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <complex>
#include <cctype>
#include <cassert>

using namespace std;

int n;
string str;
int cur;

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

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

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

int term(){
	int sum = factor();
	while(cur < S.size() && (S[cur] == '*' || S[cur] == '/'){
		char op = S[cur];
		cur++;
		int b = factor();
		if(op == '*') sum *= b;
		else sum /= b;
	}
}

int factor(){
	if (S[cur] != ???(???) return number();
	cur++;
	int n = expression();
	cur++;
	return n;	
}


int main(void){

	cin >> n;

	for(int i = 0; i < n; i++){
		cur = 0;
		cin >> str;
		str.resize(str.size()-1);
		cout << expression() << endl;
	}
	
    return 0;
}