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 <cctype>
using namespace std;
typedef string::const_iterator State;

int number(State &begin);
int term(State &begin);
int expression(State &begin);
int factor(State &begin);

int number(State &begin) {
	int ret = 0;
	
	while (isdigit(*begin)) {
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	//cout << "number :: " << ret << endl;
	return ret;
}
int term(State &begin) {
	int ret = number(begin);
	
	while(1) {
		if (*begin == '*') {
			begin++;
			//cout << "go factor // *" << endl;
			ret *= factor(begin);
		}
		else if (*begin == '/') {
			begin++;
			//cout << "go factor // /" << endl;
			ret /= factor(begin);
		}
		else break;
	}
	//cout << "term :: " << ret << endl;
    return ret;
}
int expression(State &begin) {
	int ret = term(begin);
	
	while(1) {
		if (*begin == '+') {
			begin++;
			//cout << "go term // +" << endl;
			ret += term(begin);
		}
		else if (*begin == '-') {
			begin++;
			//cout << "go term // -" << endl;
			ret -= term(begin);
        }
        else break;
	}
	//cout << "expression :: " << ret << endl;
	return ret;
}
int factor(State &begin) {
	if (*begin == '(') {
		begin++; 
		//cout << "go expression" << endl;
		int ret = expression(begin);
		//cout << "factor :: " << ret << endl;
		begin++;
		return ret;
	}
	else return number(begin);
}

int main(void) {
	int n;
	cin >> n;
	cin.ignore();
	for (int i = 0; i < n; i++) {
		string s;
		getline(cin, s);
		
		State begin = s.begin();
		//cout << "Start !!!" << endl;
		cout << expression(begin) << endl;
	}
	return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define INF 1000000


int ar[2][14];
int main(){
	string str;
	int N;
	cin>>N;
	VI res;
	stack <string>st;
	REP(ii,N){
		cin>>str;
		priority_queue<pair<int,char> > buf;
		priority_queue<pair<int,char> > buf2;
		
		bool ch=false;
		int t=0;
		vector<string> temp;
		REP(i,SZ(str)){
			if(str[i]=='+'||str[i]=='-'){
				if((!ch&&(buf.empty()||(buf.top()).first<i))||(ch&&(buf2.empty()||(buf2.top()).first<i))){
					if(!ch){
						buf.push(MP(i,str[i]));
					}else{
						buf2.push(MP(i,str[i]));
					}
				}else{
					if(!ch){
						temp.PB(toString((buf.top()).second));
						buf.pop();
						buf.push(MP(i,str[i]));
					}else{
						temp.PB(toString((buf2.top()).second));
						buf2.pop();
						buf2.push(MP(i,str[i]));
					}
				}
			}else if(str[i]=='*'||str[i]=='/'){
				if(!ch){
					buf.push(MP(300-i,str[i]));
				}else{
					buf2.push(MP(300-i,str[i]));
				}
			}else if(str[i]=='('){
				ch=true;
			}else if(str[i]==')'){
				while(!buf2.empty()){
					temp.PB(toString((buf2.top()).second));
					buf2.pop();
				}
				ch=false;
			}else if(str[i]=='='){
				while(!buf.empty()){
					temp.PB(toString((buf.top()).second));
					buf.pop();
				}
			}else if(str[i]>='0'&&str[i]<='9'){
				if(i+1<SZ(str)&&str[i+1]>='0'&&str[i+1]<='9'){
					t+=(unsigned int)(str[i]-'0');
					t*=10;
				}else{
					t+=(unsigned int)(str[i]-'0');
					//cout<<t<<endl;
					temp.PB(toString(t));
					t=0;
				}
			}
		}
		REP(i,SZ(temp))cout<<temp[i];
		cout<<endl;
		stack <int> st;
		REP(i,SZ(temp)){
			if(temp[i]=="+"){
				int t1=st.top();
				st.pop();
				int t2=st.top();
				st.pop();
				st.push(t1+t2);
			}else if(temp[i]=="-"){
				int t1=st.top();
				st.pop();
				int t2=st.top();
				st.pop();
				st.push(t2-t1);
			}else if(temp[i]=="*"){
				int t1=st.top();
				st.pop();
				int t2=st.top();
				st.pop();
				st.push(t1*t2);
			}else if(temp[i]=="/"){
				int t1=st.top();
				st.pop();
				int t2=st.top();
				st.pop();
				st.push(t2/t1);
			}else{
				st.push(toInt(temp[i]));
			}
		}
		cout<<st.top()<<endl;
		st.pop();
		
	}
	return 0;
}

//5+4*3+2/6=
//(1+4)*(3+7)/5=
//5+4-3=
//(1+5)*(2+3)=

C++: 
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <complex>
#include <cctype>
#include <cassert>

using namespace std;

int n;
string S;
int cur;

int digit(){
	assert(isdigit(S[cur]));
	int n = S[cur] - '0';
	cur++;
	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++;
	int n = expression();
	cur++;
	return n;	
}

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

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





int main(void){

	cin >> n;

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