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>
using namespace std;
string str;
int p;

int exp();
int factor();
int term();

int factor() {
  int num=0;
  while('0' <= str[p] && str[p] <= '9') {
    num*=10;
    num += str[p] - '0';
    p++;
  }

  if (str[p] == '('){
    p++;
    num = exp();
  }
  if(str[p] == ')'){
    p++;
  } 
  return num;
}

int term(){
 int val = factor();
  while(str[p] == '*' || str[p] == '/') {
    if(str[p] == '*') {
      p++;
      val *= factor();
    } else if(str[p] == '/'){
      p++;
      val /= factor();
    }
  }

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

  return val;
}

int main() {
  int n;

  cin >> n;
  
  for(int i=0;i<n;i++) {
    p = 0;
  cin >> str;
  cout << exp() << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cctype>
#include <cassert>
using namespace std;

string S;
int cur;
int expression();
char readerchar()
{
    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 = readerchar() - '0';
    return n;
}
int number()
{
    int n=digit();
    while(cur<S.size() && isdigit(peek()))
        n = n*10 + digit();
    return n;
}
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 = readerchar();
        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 = readerchar();
        int b = term();
        if(op == '+')
            a += b;
        else
            a -= b;
    }
    return a;
}


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

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 (int 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;
}

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

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

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

    scanf("%d", &n);

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

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

        cout << calculate(t, B) << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <cctype>
#include<cassert>
using namespace std;
size_t cur=0;
string S;



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

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

int expression();

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


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


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


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

C++: #include<iostream>
#include<cassert>
using namespace std;
string s;
size_t cur=0;
int digit()
{
    assert(isdigit(s[cur]));
    int n=s[cur]-'0';
    cur=cur+1;
    return n;
};
int number()
{
    int n=digit();
    while(cur<s.size()&&isdigit(s[cur]))
        n=n*10+digit();
    return n;
};
double expression();
double factor()
{
    if(s[cur]!='(')
        return number();
    cur++;
    double n=expression();
    assert(s[cur]==')');
    cur++;
    return n;
};
double term()
{
    double a=factor();
    while(cur<s.size()&&(s[cur]=='*'||s[cur]=='/'))
    {
        char op=s[cur++];
        int b=factor();
        if(op=='*')
            a*=b;
        else
            a/=b;
    }
    return a;
};


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

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