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 <map>
#include <algorithm>
#include <cctype>
using namespace std;

typedef string::const_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;
}

C++: #include<iostream>
#include<cassert>
#include<algorithm>
#include<cstdio>
using namespace std;

char *pt;
int parseAtom();
int parseExpr();
int parseTerm();


int parseAtom(){
	if('0' <= *pt && *pt <= '9'){
		int x = *pt - '0';
		pt++;
		while('0' <= *pt && *pt <= '9'){
			x = x * 10 + *pt - '0';
			pt++;
		}
		return x;
	}
	if('(' == *pt){
		pt++;
		int x = parseExpr();
		assert(*pt == ')');
		pt++;
		return x;
	}
	assert(false);
	return -1;
}
int parseExpr(){
	int x = parseTerm();
	while(*pt == '+' || *pt == '-'){
		if(*pt == '+'){
			pt++;
			x += parseTerm();
		}else {
			pt++;
			x -= parseTerm();
		}
	}
	return x;
}
int parseTerm(){
	int x = parseAtom();
	while(*pt == '*' || *pt == '/'){
		if(*pt == '*'){
			pt++;
			x *= parseAtom();
		} else{
			x /= parseAtom();
		}
	}
	return x;
}
int main(void){
	int n ;
	cin>>n;
	for(int i = 0 ; i < n ;  i ++){
		static char expr[200];
		scanf("%d",expr);
		pt=expr;
		int x = parseExpr();
		assert(*pt == '=');
		cout<<x<<endl;
	}
	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 res=head2Num();

    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 <iostream>
#include <string>
#include <cctype>
using namespace std;
using State = string::const_iterator;


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


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;
}


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 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(){
	int n;
	string expr;

	cin >> n;
	cin.ignore();

	for (int i = 0; i < n; i++){
		getline(cin, expr);

		State begin = expr.begin();
		int ans = expression(begin);
		cout << ans << endl;
	}

	return 0;
}

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

int p;
string str;

int Term();
int Factor();
int Elem();
int Digit();

int Term() {
  int a = Factor();
  while (str[p] == '+' || str[p] == '-') {
    char c = str[p];
    p++; // read [+-]
    int b = Factor();
    if (c == '+') {
      a = a + b;
    } else {
      a = a - b;
    }
  }
  return a;
}

int Factor() {
  int a = Elem();
  while (str[p] == '*' || str[p] == '/') {
    char c = str[p];
    p++; // read [*/]
    int b = Factor();
    if (c == '*') {
      a = a * b;
    } else {
      a = a / b;
    }
  }
  return a;
}

int Elem() {
  if (str[p] == '(') {
    p++; // read (
    int a = Term();
    p++; // read )
    return a;
  } else {
    int a = 0;
    while (isdigit(str[p])) {
      int b = Digit();
      a = 10 * a + b;
    }
    return a;
  }
}

int Digit() {
  int a = str[p] - '0';
  p++; // read [0-9]
  return a;
};

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> str;
    p = 0;
    cout << Term() << endl;
  }
}