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>
using namespace std;
int exp();
int term();
int factor();
int number();
int digit();
int p=0;
string str;
int main(){
  int n,re;
  cin >> n;
  while(n){
    p=0;
    cin >> str;
    re=exp();
    cout << re << endl;
    n--;
  }
  return 0;
}
int exp(){
  int val=term();
  while(str[p]=='+'||str[p]=='-'){
    if(str[p]=='+'){
      p++;
      val+=term();
    }else if(str[p]=='-'){
      p++;
      val-=term();
    }
  }
  return val;
}
int term(){
  int val=factor();
  while(str[p]=='*'||str[p]=='/'){
    if(str[p]=='*'){
      p++;
      val*=factor();
    }else if(str[p]=='/'){
      p++;
      val/=factor();
    }
  }
  return val;
}
int factor(){
  int val=number();
  if(str[p]=='('){
    p++;
    val=exp();
  }else if(str[p]==')'){
    p++;
  }
  return val;
}
int number(){
  int val=digit();
  return val;
}
int digit(){
  int ret;
  if(str[p]=='0'||str[p]=='1'||str[p]=='2'||str[p]=='3'||str[p]=='4'||str[p]=='5'||str[p]=='6'||str[p]=='7'||str[p]=='8'||str[p]=='9'){
    ret=str[p]-'0';
    p++;
    if(str[p]=='0'||str[p]=='1'||str[p]=='2'||str[p]=='3'||str[p]=='4'||str[p]=='5'||str[p]=='6'||str[p]=='7'||str[p]=='8'||str[p]=='9'){
      ret=(str[p-1]-'0')*10+(str[p]-'0');
      digit();
    }
    return ret;
  }
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int expr(string& s, int& i);
int term(string& s, int& i);
int factor(string& s, int& i);
int number(string& s, int& i);

int expr(string& s,int& i) {
	int a = term(s, i);
	while (s[i] == '+' || s[i] == '-') {
		char op = s[i];
		i++;
		int b = term(s, i);
		if (op == '+') {
			a = a+b;
		}
		else {
			a = a - b;
		}
	}
	return a;
}

int term(string& s, int& i) {
	int a = factor(s, i);
	while (s[i] == '*' || s[i] == '/') {
		char op = s[i];
		i++;
		int b = factor(s, i);
		if (op == '*') {
			a = a*b;
		}
		else {
			a = a / b;
		}
	}
	return a;
}

int factor(string& s, int& i) {
	if (isdigit(s[i])) {
		int a = number(s, i);
		return a;
	}
	else {
		i++;//(
		int a = expr(s, i);
		i++;//)
		return a;
	}
}

int number(string& s, int& i) {
	int a = s[i]-'0';
	i++;
	while (isdigit(s[i])) {
		a = a * 10 + (s[i] - '0');
		i++;
	}
	return a;
}

int main()
{
	int n;
	cin >> n;
	REP(j, n) {
		string ss;
		cin >> ss;
		int k = 0;
		cout << expr(ss, k) << endl;
	}

}

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

typedef string::iterator State;
int n;
string str;

int factor(State begin);
int number(State begin);
int term(State begin);
int expressin(State begin);

int factor(State begin)
{
	int ret;
	if (*begin == '(')
	{
		begin++;
		ret = expressin(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 term(State begin)
{
	int ret = factor(begin);
	while (true)
	{
		if (*begin == '*')
		{
			begin++;
			ret *= factor(begin);
		}
		else if (*begin == '/')
		{
			begin++;
			ret /= factor(begin);
		}
		else
		{
			break;
		}
	}

	return ret;
}

int expressin(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;
}


int main()
{
	cin >> n;
	while (n--)
	{
		cin >> str;
		cout << expressin(str.begin()) << endl;
	}

	return 0;
}