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 <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>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <stack>

using namespace std;

int calc(string s){
	// ©gªÊÉÍÜêÄ¢éêÆAÅ éÆ«Ì
	if(s[0]>='0'&&s[0]<='9'){
		bool f=false;
		for(int i = 0; i < s.size(); i++){
			if(!(s[i]>='0'&&s[i]<='9')){
				f=true;
				break;
			}
		}
		if(!f){
			return atoi(s.c_str());
		}
	}
	else if(s[0]=='('){
		stack<char> sc;
		sc.push('(');
		for(int i = 1; i < s.size(); i++){
			if(s[i]==')')
				sc.pop();
			else if(s[i]=='('){
				sc.push('(');
			}
			if(sc.size()==0){
				if(i==s.size()-1){
					return calc(s.substr(1,s.size()-2));
				}
				else{
					break;
				}
			}
		}
	}
	stack<char> sc;
	// \¶ðÍÆÓ¡ðÍ
	for(int i = 0; i < s.size(); i++){
		// ÊÌÌZqÍ³·é
		if(s[i]=='(')
			sc.push('(');
		else if(s[i]==')'){
			sc.pop();
		}
		else if(s[i]=='+'&&sc.size()==0){
			return calc(s.substr(0,i)) + calc(s.substr(i+1,s.size()-i-1));
		}
		else if(s[i]=='-'&&sc.size()==0){
			return calc(s.substr(0,i)) - calc(s.substr(i+1,s.size()-i-1));
		}
	}

	for(int i = 0; i < s.size(); i++){
		// ÊÌÌZqÍ³·é
		if(s[i]=='(')
			sc.push('(');
		else if(s[i]==')'){
			sc.pop();
		}
		else if(s[i]=='*'&&sc.size()==0){
			return calc(s.substr(0,i)) * calc(s.substr(i+1,s.size()-i-1));
		}
		else if(s[i]=='/'&&sc.size()==0){
			return calc(s.substr(0,i)) / calc(s.substr(i+1,s.size()-i-1));
		}
	}
}

int main(){

	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		string str;
		cin>>str;
		cout<<calc(str.substr(0,str.size()-1))<<endl;
	}

	return 0;
}

C++: #include<iostream>
#include<string>

using namespace std;

/*
 exp    ::= term    | exp  + term   | exp  - term
 term   ::= factor  | term * factor | term / factor
 factor ::= literal | (exp) | -factor
*/

int perseExp( string str );
int perseTerm( string str );
int perseFactor( string str );

int perseExp( string str ){
  int  nest = 0;
  char op   = 0;
  int pos;
  for(int i=str.size()-1; i>0; i--){
    char c = str[i];
    if(nest == 0 && (c == '+' || c == '-')){
      op = c;
      pos = i;
      break;
    }
    if(c == '('){
      nest--;
    }else if(c == ')'){
      nest++;
    }
    if(nest < 0)
      throw "Error: perseExp";
  }
  if(op == 0){
    return perseTerm(str);
  }else{
    int op1 = perseExp( str.substr(0, pos) );
    int op2 = perseTerm( str.substr(pos+1) );
    if(op == '+'){
      return op1 + op2;
    }else{
      return op1 - op2;
    }
  }
}

int perseTerm( string str ){
  int nest = 0;
  char op = 0;
  int pos;
  for(int i=str.size()-1; i>0; i--){
    char c = str[i];
    if(nest == 0 && (c == '*' || c == '/')){
      op = c;
      pos = i;
      break;
    }
    if(c == '('){
      nest--;
    }else if(c == ')'){
      nest++;
    }
    if(nest < 0)
      throw "Error: perseTerm";
  }
  if(op == 0){
    return perseFactor(str);
  }else{
    int op1 = perseTerm( str.substr(0, pos) );
    int op2 = perseFactor( str.substr(pos+1) );
    if(op == '*'){
      return op1 * op2;
    }else{
      return op1 / op2;
    }
  }
}

int perseFactor( string str ){
  if(str.size() == 0)
    throw "Parse Error: perseFactor";

  char firstStr = str[0];
  if(firstStr == '('){
    return perseExp( str.substr(1, str.size()-1) );
  }else if(firstStr == '-'){
    return -1 * perseFactor( str.substr(1) );
  }else{
    int num;
    sscanf(str.c_str(), "%d", &num);
    return num;
  }
}


int main(){
  int n;
  cin>>n;
  while(n-->0){
    string str;
    cin >> str;
    str = str.substr(0, str.size()-1);
    int ret = perseExp(str);
    cout << ret << 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 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 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);
        for (int j = 0; j < t; j++)
            cout << B[j] << " ";
        cout << endl;

        calculate(t, B);
    }

    return 0;
}