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 <vector>
using namespace std;

int getNumber( string& str, int* index )
{
	int ret = 0;
	while( *index < (int)str.size() ){
		if( str[ *index ] < '0' || str[ *index ] > '9' ){
			break;
		}
		ret *= 10;
		ret += ( str[ *index ] - '0' );
		++(*index);
	}
	return ret;
}

double rec( string& formula, int* index )
{
	double ret = 0;
	vector<double> num_list;
	vector<char> sign_list( 1, '.' );
	bool end = false;

	while( !end && *index < (int)formula.size() ){
		if( formula[ *index ] >= '0' && formula[ *index ] <= '9' ){
			num_list.push_back( getNumber( formula, index ) );
			continue;
		}else{
			switch( formula[ *index ] ){
				case '(':
					++(*index);
					num_list.push_back( rec( formula, index ) );
					break;
				case ')':
				case '=':
					++(*index);
					end = true;
					break;
				default:
					sign_list.push_back( formula[ *index ] );
					++(*index);
					break;
			}
		}
	}

	vector<double> num2_list;
	vector<char> sign2_list( 1, '.' );

	for( int i = 0; i < (int)num_list.size(); ++i ){
		double num = num_list[ i ];
		switch( sign_list[ i ] ){
			case '.':
				ret = num;
				break;
			case '*':
				ret *= num;
				break;
			case '/':
				ret /= num;
				break;
			default:
				num2_list.push_back( ret );
				ret = num;
				sign2_list.push_back( sign_list[ i ] );
				break;
		}
	}
	num2_list.push_back( ret );

	for( int i = 0; i < (int)num2_list.size(); ++i ){
		double num = num2_list[ i ];
		switch( sign2_list[ i ] ){
			case '.':
				ret = num;
				break;
			case '+':
				ret += num;
				break;
			case '-':
				ret -= num;
				break;
		}
	}

	return ret;
}

int solve( string& formula ){
	int index = 0;
	return (int)rec( formula, &index );
}

int main()
{
	int n;
	cin >> n;

	for( int i = 0; i < n; ++i ){
		string formula;
		cin >> formula;
		cout << solve( formula ) << endl;
	}

	return 0;
}

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

string s;
int N;
int c;

int expr();
int term();
int factor();
int num();

void debug(string text){
	return;
	cout << text + " ";
	for(int i = 0; i < N; i++){
		if(i == c) cout << '[' << s[i] << ']';
		else cout << s[i];
	}
	cout << endl;
}

int expr(){
	debug("expr");
	int x = term();
	while(c < N){
		if(s[c] == '+'){
			c++;
			x += term();
		}
		else if(s[c] == '-'){
			c++;
			x -= term();
		}
		else break;
	}
	return x;
}

int term(){
	debug("term");
	int x = factor();
	while(c < N){
		if(s[c] == '*'){
			c++;
			x *= factor();
		}
		else if(s[c] == '/'){
			c++;
			x /= factor();
		}
		else break;
	}
	return x;
}

int factor(){
	debug("factor");
	if(s[c] == '('){
		c++;
		int ret = expr();
		assert(s[c] == ')');
		c++;
		return ret;
	}
	return num();
}

int num(){
	debug("num");
	int ret = 0;
	while(c < N && isdigit(s[c])){
		ret = ret * 10 + s[c] - '0';
		c++;
	}
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int n;
	cin >> n;
	while(n--){
		cin >> s;
		s.pop_back();
		N = s.size();
		c = 0;
		cout << expr() << endl;
	}
}

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

using namespace std;

string toReversePorland(string str){
  string hand;
  string side;

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

  for(int i = 0; i < str.size(); i++){
    //    cout << str[i] << endl;                                                          
    //    cout << hand << endl;                                                            
    //    cout << side << endl;                                                            

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

    else{
      if(side.size() == 0){
        side += str[i];
      }
      else if(str[i] == '+' || str[i] == '-'){
        if(side[side.size()-1] == '*' || side[side.size()-1] == '/'){
          hand += side[side.size()-1];
          side[side.size()-1] = str[i];
        }
        else{
          //      cout << str[i] << endl;                                                  
          side += str[i];
        }
      }
      else{
        if(side[side.size()-1] == '*' || side[side.size()-1] == '/'){
          hand += side[side.size()-1];
          side[side.size()-1] = str[i];
        }
        else
          side += str[i];
      }
    }
  }

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

int calc(string str){

  cout << str << endl;
  //  string stack;                                                                        
  stack<int> st;
  for(int i = 0; i < str.size(); i++){
    if(str[i] >= '0' && str[i] <= '9'){
      st.push(str[i] - '0');
    }
    else{
      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]);
      }
    }
  }
  return st.top();
}

int main(){

  string str;
  getline(cin,str);

  cout << calc(toReversePorland(str)) << endl;

  return 0;
}