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){
  //  string hand;                                                                   
  //  string side;                                                                   

  vector<string> hand;
  vector<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'){
      //      cout << str[i] << endl;                                                
      string num;
      while(i < str.size()){
        if(str[i] < '0' || str[i] > '9'){
          //      hand += str[i];                                                    
  	  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ðêÂ¸Âè³Éß·                                        
      //      cout << side << endl;                                                  
      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){

  //  cout << str << endl;                                                           
  //  string stack;                                                                  
  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;
  //  cin >> n;                                                                      
  string s;
  getline(cin,s);
  n = atoi(s.c_str());
  char h;
  //  cin >> h;                                                                      

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

  return 0;
}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef pair<ll,const char*> parsed;

parsed expr(const char*);
parsed term(const char*);
parsed fact(const char*);

parsed expr(const char* s)
{
	//cout<<"expr(\""<<s<<"\")"<<endl;
	parsed now=term(s);
	while(*now.second=='+' || *now.second=='-'){
		char op=*now.second;
		parsed next=term(now.second+1);
		if(op=='+')
			now=parsed(now.first+next.first,next.second);
		else
			now=parsed(now.first-next.first,next.second);
	}
	//cout<<"expr(\""<<s<<"\")="<<now.first<<endl;
	return now;
}

parsed term(const char* s)
{
	//cout<<"term(\""<<s<<"\")"<<endl;
	parsed now=fact(s);
	while(*now.second=='*' || *now.second=='/'){
		char op=*now.second;
		parsed next=fact(now.second+1);
		if(op=='*')
			now=parsed(now.first*next.first,next.second);
		else
			now=parsed(now.first/next.first,next.second);
	}
	//cout<<"term(\""<<s<<"\")="<<now.first<<endl;
	return now;
}

parsed fact(const char* s)
{
	//cout<<"fact(\""<<s<<"\")"<<endl;
	//if(s[0]=='('){
	//	parsed res=expr(s+1);
	//	res.second++;
	//	return res;
	//}
	//else{
	//	const char* p=s;
	//	if(*p=='-')
	//		p++;
	//	ll n=0;
	//	while(isdigit(*p)){
	//		n=n*10+*p-'0';
	//		p++;
	//	}
	//	return parsed(n,p);
	//}
	
	if(s[0]=='-' || isdigit(s[0])){
		const char* p=s;
		if(*p=='-')
			p++;
		ll n=0;
		while(isdigit(*p)){
			n=n*10+(*p-'0');
			p++;
		}
		return parsed(n,p);
	}
	else if(s[0]=='('){
		parsed res=expr(s+1);
		res.second++;
		return res;
	}
	else
		exit(0);
}

int main()
{
	int n;
	cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		cout<<expr(s.c_str()).first<<endl;
	}
	//string s;
	//getline(cin,s);
	//while(getline(cin,s))
	//	cout<<expr(s.c_str()).first<<endl;
	
	return 0;
}