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

using namespace std;

vector<string> toReversePorland(string str){

  vector<string> hand;
  vector<string> side;

  // ÊàtO
  bool isInside = false;    

  for(int i = 0; i < str.size(); i++){
    //    cout << str[i] << endl;
    if(str[i] >= '0' && str[i] <= '9'){
      string num;
      while(i < str.size()){
	if(str[i] < '0' || str[i] > '9'){
	  break;
	}
	num += str[i];
	i++;
      }
      hand.push_back(num);
      i--;
    }
    else if(str[i] == '('){
      isInside = true;
      string tmp;
      tmp += str[i];
      side.push_back(tmp);
    }
    else if(isInside && str[i] == ')'){
      // EÊÜÅZqðêÂ¸Âè³Éß·
      for(int j = side.size()-1 ; ;j--){
	if(side[j] == "("){
	  if(j != 0){
	    vector<string> tmp;
	    for(int k = 0; k < j; k++){
	      tmp.push_back(side[k]);
	    }
	    side = tmp;
	  }
	  else
	    side.clear();
	  break;
	}
	else{
	  string tmp = side[j];
	  hand.push_back(tmp);
	}
      }
      isInside = false;
    }
    else{
      if(side.size() == 0){
	string tmp;
	tmp += str[i];
	side.push_back(tmp);
      }
      else if(str[i] == '+' || str[i] == '-'){
	if(side[side.size()-1] == "*" || side[side.size()-1] == "/"){
	  hand.push_back(side[side.size()-1]);
	  string tmp;
	  tmp += str[i];
	  side[side.size()-1] = tmp;
	}
	else{
	  string tmp;
	  tmp += str[i];
	  side.push_back(tmp);
	}
      }
      else{
	if(side[side.size()-1] == "*" || side[side.size()-1] == "/"){
	  hand.push_back(side[side.size()-1]);
	  string tmp;
	  tmp += str[i];
	  side[side.size()-1] = string(tmp);
	}
	else{
	  string tmp;
	  tmp += str[i];
	  side.push_back(tmp);
	}
      }
    }
  }

  for(int i = side.size()-1; i >= 0; i--){
    hand.push_back(string(side[i]));
  }
  
  return hand;
}


int calc(vector<string> str){
  stack<int> st;
  for(int i = 0; i < str.size(); i++){
    if(str[i] == "+" || str[i] == "-" || str[i] == "*" || str[i] == "/"){
      int val[2];
      val[0] = st.top();
      st.pop();
      val[1] = st.top();
      st.pop();
      if(str[i] == "+"){
	st.push(val[0] + val[1]);
      }
      if(str[i] == "-"){
	st.push(val[1] - val[0]);
      }
      if(str[i] == "*"){
	st.push(val[0] * val[1]);
      }
      if(str[i] == "/"){
	st.push(val[1] / val[0]);
      }
    }
    else{
      st.push(atoi(str[i].c_str()));
    }
  }
  return st.top();
}

int main(){

  int n = 1;
  string s;
  getline(cin,s);
  n = atoi(s.c_str());

  for(int i = 0; i < n; i++){
    string str;
    getline(cin,str);
    str = str.substr(0,str.size()-1);
    // vector<string> vec = toReversePorland(str);
    // for(int i = 0; i < vec.size(); i++)
    //   cout << vec[i] << endl;
    
    cout << calc(toReversePorland(str)) << endl;
  }
  
  return 0;
}

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

using namespace std;

class myCalc {
private:
	std::map<char, int> mOperator;
public:
	myCalc( void ) {
		mOperator['('] = -2;
		mOperator[')'] = -1;
		mOperator['+'] = 0;
		mOperator['-'] = 1;
		mOperator['/'] = 2;
		mOperator['*'] = 2;
	}
	std::string ToRPN( std::string str ) {
		std::string ret;
		std::stack<char> st;
		int len = str.size(), i = 0;
		while(i < len) {
			switch(str[i]) {
			case '+' :
				while(!st.empty() && mOperator[st.top()] > mOperator[str[i]]) {
						ret += st.top(); st.pop();
				}
			case '(':
				st.push(str[i++]);
				break;
			case '-': case '/': case '*':
				while(!st.empty() && mOperator[st.top()] >= mOperator[str[i]]) {
					ret += st.top(); st.pop();
				}
				st.push(str[i++]);
				break;
			case ')':
				while(!st.empty() && st.top() != '(') {
					ret += st.top();
					st.pop();
				}
				st.pop();
				++i;
				break;
			default:
				ret += '[';
				while('0' <= str[i] && str[i] <= '9') ret += str[i++];
				ret += ']';
				break;
			}
		}
		while(!st.empty()) { ret += st.top(); st.pop(); }
		return ret;
	}
	int Calculate( std::string str ) {
		std::stack<int> st;
		int len = str.size(), i = 0;
		while(i < len) {
			int a, b;
			switch(str[i]) {
			case '+':
				a = st.top(); st.pop();
				b = st.top(); st.pop();
				st.push(a+b);
				break;
			case '-':
				a = st.top(); st.pop();
				if(!st.empty()) {b = st.top(); st.pop();}
				else b = 0;
				st.push(b-a);
				break;
			case '*':
				a = st.top(); st.pop();
				b = st.top(); st.pop();
				st.push(a*b);
				break;
			case '/':
				a = st.top(); st.pop();
				b = st.top(); st.pop();
				st.push(b/a);
				break;
			default:
				++i; a = 0;
				while(str[i] != ']') {
					a *= 10;
					a += (str[i++] - '0');
				}
				st.push(a);
				break;
			}
			++i;
		}
		return st.top();
	}
};

int main( void )
{
	long long n;
	myCalc calc;
	cin >> n;
	while(n--) {
		string in;
		cin >> in;
		in.erase(in.size()-1);
		//cout << in << ' ' << calc.ToRPN(in) << endl;
		cout << calc.Calculate(calc.ToRPN(in)) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

template<class T>
struct Parse{
    typedef string::const_iterator itr;
    itr begin;
    T ans;
    Parse(const string &s){
        begin=s.begin();
        ans=expr(begin);
        cerr<<s<<" "<<ans<<"\n";
    }
    T expr(itr &begin){
        T ret=term(begin);
        while(1){
            if((*begin)=='+'){
                consume(begin,'+');
                ret+=term(begin);
            }else if((*begin)=='-'){
                consume(begin,'-');
                ret-=term(begin);
            }else{
                return ret;
            }
        }
    }
    T numb(itr &begin){
        T ret=0;
        while('0'<=(*begin)&&(*begin)<='9'){
            ret*=10;
            ret+=(*begin)-'0';
            begin++;
        }
        return ret;
    }
    T fact(itr &begin){
        T ret=0;
        if((*begin)=='('){
            consume(begin,'(');
            ret=expr(begin);
            consume(begin,')');
        }else{
            ret=numb(begin);
        }
        return ret;
    }
    T term(itr &begin){
        T ret=fact(begin);
        while(1){
            if((*begin)=='*'){
                consume(begin,'*');
                ret*=fact(begin);
            }else if((*begin)=='/'){
                consume(begin,'/');
                ret/=fact(begin);
            }else{
                return ret;
            }
        }
    }
    void consume(itr &begin,char expected){
        if(*begin==expected){
            begin++;
        }else{
            fprintf(stderr,"Expected: '%c' Got: '%c'\n",expected,*begin);
            fprintf(stderr,"Rest string is ");
            while(*begin){
                fprintf(stderr,"%c",*begin++);
            }
            throw;
        }
    }
};

int main(){
    int n; cin>>n;
    while(n--){
        string s; cin>>s;
        Parse<int> parse(s);
        cout<<parse.ans<<endl;
    }
    return 0;
}