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 <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(5)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<short, short> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int calc(string s)
{
	vi v;
	REP(i, s.size())
	{
		if (s[i] == '+') v.push_back(0);
		else if (s[i] == '-') v.push_back(1);
		else if (s[i] == '*') v.push_back(2);
		else if (s[i] == '/') v.push_back(3);
		else
		{
			int tmp = s[i] - '0';
			int t = i+1;
			while (isdigit(s[t]))
			{
				tmp = tmp * 10 + s[t] - '0';
				t++;
			}
			i = t - 1;
			v.push_back(tmp);
		}
	}

	while (v.size() > 1)
	{
		for (int i = 1; i < v.size();i+=2)
		{
			if (v[i]==2)
			{
				int tmp = v[i - 1] * v[i + 1];
				v[i - 1] = tmp;
				v.erase(v.begin() + i + 1);
				v.erase(v.begin() + i);
				continue;
			}
			else if (v[i] == 3)
			{
				int tmp = v[i - 1] / v[i + 1];
				v[i - 1] = tmp;
				v.erase(v.begin() + i + 1);
				v.erase(v.begin() + i);
				continue;
			}
		}
		for (int i = 1; i < v.size(); i += 2)
		{
			if (v[i] == 0)
			{
				int tmp = v[i - 1] + v[i + 1];
				v[i - 1] = tmp;
				v.erase(v.begin() + i + 1);
				v.erase(v.begin() + i);
				break;
			}
			else if (v[i] == 1)
			{
				int tmp = v[i - 1] - v[i + 1];
				v[i - 1] = tmp;
				v.erase(v.begin() + i + 1);
				v.erase(v.begin() + i);
				break;
			}
		next:;
		}
	}
	return v[0];
}

int solve(string s)
{
	while (1)
	{
		if (find(ALL(s), '(') == s.end())
		{
			return calc(s);
		}
		else
		{
			string tmp;
			REP(i, s.size())
			{
				if (s[i] != '(') tmp.push_back(s[i]);
				else
				{
					int j;
					for (j = i;; j++)
					{
						if (s[j] == ')')
						{
							int t = solve(s.substr(i+1, j - i - 1));
							tmp += to_string(t);
							break;
						}
						else if (s[j] == '(') i = j;
					}
					i = j;
				}
			}
			return solve(tmp);
		}
	}
	return 0;
}

int main()
{
	int sets;
	string s;
	cin >> sets;
	REP(set, sets)
	{
		cin >> s;
		s.erase(s.size() - 1);
		cout << solve(s) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef string::const_iterator State;
#define rep(i,n) for(int i=0;i<(n);i++)

class Parser{
public:
    int expression(State &begin){
        int ret = term(begin);
        for(;;){
            if(*begin == '+'){
                begin++;
                ret += term(begin);
            }else if(*begin == '-'){
                begin++;
                ret -= term(begin);
            }else{
                break;
            }
        }
        return ret;
    }
    int term(State &begin){
        int ret = factor(begin);
        for(;;){
            if(*begin == '*'){
                begin++;
                ret *= factor(begin);
            }else if(*begin == '/'){
                begin++;
                ret /= factor(begin);
            }else{
                break;
            }
        }
        return ret;
    }
    int factor(State &begin){
        int ret;
        if(*begin == '('){
            begin++;//'('?????????
            ret = expression(begin);
            begin++;//')'?????????
        }else{
            ret = number(begin);
        }
        return ret;
    }
    int number(State &begin){
        int ret = 0;
        while(isdigit(*begin)){
            ret *= 10;
            ret += *begin - '0';
            begin++;
        }
        return ret;
    }
};

int main(void){
    int n; cin >> n;
    rep(i, n){
        Parser ps;
        string s; cin >> s;
        string tmp = s.substr(0, s.size() - 1);
   //     cout << tmp << endl;
        State begin = s.begin();
        int ret = ps.expression(begin);
        printf("%d\n", ret);
    }
    return 0;
}

C++: #include <cctype>
#include <cassert>
#include <string>
#include <iostream>
using namespace std;


string S;
size_t cur = 0;
int parse();
int expression();


int digit(){
  // assert(isdigit(S[cur]));
  int n = S[cur]-'0';
  cur =cur+1;
  // cout << n <<endl;
  return n;
}

int number (){
  int n = digit();
  // cout << n << endl;
  while(cur<S.size() && isdigit(S[cur])) n=n*10 + digit();
  // cout << n<<endl;
  return n;
}

int factor(){
  if(S[cur] != '('){
    return number();
  }
  cur += 1;
  int n = expression();
  assert(S[cur]==')');
  cur+=1;
  return n;
}

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

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

  //   }

  // }


  // int a = number();
  // char op = S[cur];
  // cur += 1;
  // int b = number();
  // assert(op == '+');
  // return a + b;
}



int main(){
  int N;
  cin >> N;
  for (int i=0;i<N;++i){
    cur=0;
    cin>>S;
    S.resize(S.size()-1);
    cout << expression()<<endl;
  }
}
// int parse(){return expression();}
// int main(){
//   int a = parse();
//   // assert(a==15);
//   cout << a << endl;
//   assert(cur == S.size());
// }

C++: #include<iostream>
#include<string>
using namespace std;

int p;
string exp;

int term();
int expression();
int factor();


int expression(){
     int value;
	 value=term();
	 while(exp[p]=='+' || exp[p]=='-'){
		 if(exp[p]=='+'){
			 p++;
			 value+=term();
		 }
		 else{
			 p++;
			 value-=term();
		 }
	 }
	 p++;
	 return value;
}


int term(){
	int value;
	value=factor();
	while(exp[p]=='*' || exp[p]=='/'){
		if(exp[p]=='*'){
			p++;
			value*=factor();
		}
		else{
			p++;
			value/=factor();
		}
	}

	return value;
}

int factor(){
	int value=0;
	if(exp[p]=='('){
		value=expression();
	}
	else{
		while(isdigit(exp[p])){
			value=value*10+exp[p++]-'0';
		}
	}
	return value;
}



int main()
{
	int i,c;
	cin>>c;
	for(i=0;i<c;i++){
		cin>>exp;
		p=0;
		cout<<expression()<<"\n";
		}
	cout<<"\n";
	return 0;
}