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 <stack>

using namespace std;

int pri(char ch) 
{
    if (ch == '*' || ch == '/')
        return 2;
    if (ch == '+' || ch == '-')
        return 1;
    else
        return 0;
}

int main()
{
    int n;

    cin >> n;

    while (n--) {
        string exp, cha;
        stack<char> pol;
        stack<int> cal;

        cin >> exp;
        for (int i = 0; i < exp.size() - 1; i++) {
            if ('0' <= exp[i] && exp[i] <= '9')
                cha.push_back(exp[i]);
            else if (exp[i] == '(')
                pol.push(exp[i]);
            else if (exp[i] == ')') {
                while (true) {
                    if (pol.top() == '(') {
                        pol.pop();
                        break;
                    }
                    cha.push_back(pol.top());
                    pol.pop();

                }
            }
            else {
                while (!pol.empty()) {
                    if (pri(exp[i]) < pri(pol.top())) {
                        cha.push_back(pol.top());
                        pol.pop();
                    }
                    else 
                        break;
                }
                pol.push(exp[i]);
            }
        }

        while (!pol.empty()) {
            cha.push_back(pol.top());
            pol.pop();
        }

        for (int i = 0; i < cha.size(); i++) {
            if ('0' <= cha[i] && cha[i] <= '9')
                cal.push(cha[i] - '0');
            else {
                int a, b;

                b = cal.top();
                cal.pop();
                a = cal.top();
                cal.pop();

                if (cha[i] == '*') 
                    cal.push(a * b);
                else if (cha[i] == '/') 
                    cal.push(a / b);
                else if (cha[i] == '+') 
                    cal.push(a + b);
                else if (cha[i] == '-') 
                    cal.push(a - b);
            }
        }
        cerr << exp << endl;
        cout << cal.top() << endl;
    }

    return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

namespace parser{

typedef string::const_iterator state;
class parse_error{};

int number(state&);
int factor(state&);
int term(state&);
int expression(state&);

// 数字の列をパースして、その数を返す。
int number(state &begin){
    int res=0;
    while(isdigit(*begin)){
        res*=10;
        res+=*begin-'0';
        ++begin;
    }
    return res;
}

// 括弧か数をパースして、その評価結果を返す。
int factor(state &begin){
    if(*begin=='('){
        ++begin;
        int res=parser::expression(begin);
        ++begin;
        return res;
    }else return parser::number(begin);
}

// 乗算除算の式をパースして、その評価結果を返す。
int term(state &begin){
    int res=parser::factor(begin);
    while(true){
        if(*begin=='*'){
            ++begin;
            res*=parser::factor(begin);
        }else if(*begin=='/'){
            ++begin;
            res/=parser::factor(begin);
        }else break;
    }
    return res;
}

// 四則演算の式をパースして、その評価結果を返す。
int expression(state &begin){
    int res=parser::term(begin);
    while(true){
        if(*begin=='+'){
            ++begin;
            res+=parser::term(begin);
        }else if(*begin=='-'){
            ++begin;
            res-=parser::term(begin);
        }else break;
    }
    return res;
}
}

void solve(){
    int n;
    cin >> n;
    cin.ignore();
    rep(i,0,n){
        string s;
        getline(cin,s);
        
        parser::state begin=s.begin();
        int ans=parser::expression(begin);
        cout << ans << endl;
    }
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
using namespace std;
#define INF (1<<24)

bool isNum(char ch){return ('0'<=ch&&ch<='9');}

struct calcStr{
  string s;
  int pos,len;

  void init(){ pos=0;len=s.size();}

  int head2Num(){
    bool f=false;
    if(s[pos]=='-'){f=true;pos++;}
    int res=0;
    while(pos<len){
      if(isNum(s[pos])){
	res*=10;
	res+=(s[pos]-'0');
	pos++;
      }else break;
    }
    if(f)res*=-1;
    return res;
  }
  
  int getNum(){
    int res;
    if(s[pos]=='('){
      pos++;
      res = getAns();
    }else if(s[pos]=='-'||isNum(s[pos])){
      res=head2Num();
    }else{
      //cout<<s[pos]<<endl;
      assert(0);
    }
    
    if(s[pos]=='*'){
      pos++;
      return res*getNum();
    }else if(s[pos]=='/'){
      pos++;
      return res/getNum();
    }else{
      return res;
    }
  }
  
  int getAns(){
    int res=getNum(),num;
    while(1){
      if(s[pos]==')'){pos++;break;}
      if(s[pos]=='=')break;
      char ch=s[pos++];
      num=getNum();
      if(ch=='+')res+=num;
      else if(ch=='-')res-=num;
      else assert(0);
    }
    return res;
  }
};

int main(){
  int Tc;cin>>Tc;
  calcStr a;
  while(Tc--){
    cin>>a.s;
    a.init();
    cout<<a.getAns()<<endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

class CalcExpression
{
	typedef string::const_iterator State;
	class ParseError {};


public:

	int expression(State& begin)
	{
		int ret = term(begin);

		while(true)
		{
			if(*begin == '+')
			{
				begin++;
				ret += term(begin);
			}
			else if(*begin == '-')
			{
				begin++;
				ret -= term(begin);
			}
			else break;
		}

		return ret;
	}


private:

	int term(State& begin)
	{
		int ret = number(begin);

		while(true)
		{
			if(*begin == '*')
			{
				begin++;
				ret *= factor(begin);
			}
			else if(*begin == '/')
			{
				begin++;
				ret /= factor(begin);
			}
			else break;
		}

		return ret;
	}

	int factor(State &begin)
	{
		int ret = 0;

		if(*begin == '(')
		{
			begin++;
			ret = expression(begin);
			begin++;
		}
		else return number(begin);

		return ret;
	}

	int number(State& begin)
	{
		int ret = 0;

		while(isdigit(*begin))
		{
			ret *= 10;
			ret += *begin - '0';
			begin++;
		}

		return ret;
	}

};

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

	CalcExpression ce;
	while(n--)
	{
		string expression, buf;

		cin >> expression;

		cout << ce.expression(expression.begin()) << endl;
	}
}