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 <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <time.h>
#include <cctype>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=1e+5+10;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=1e+9 + 7;

typedef string::const_iterator SC;

int factor(SC&);

// ??°????????????
int number(SC& begin){
  int res = 0;

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

  return res;
}

// ??????
int term(SC& begin){
  int res = factor(begin);

  while(1){
    if(*begin == '*'){
      begin++;
      res *= factor(begin);
    }
    else if(*begin == '/'){
      begin++;
      res /= factor(begin);
    }
    else{
      break;
    }
  }
  return res;
}

// ????????????
int expression(SC& begin){
  int res = term(begin);

  while(1){
    if(*begin == '+'){
      begin++;
      res += term(begin);
    }
    else if(*begin == '-'){
      begin++;
      res -= term(begin);
    }
    else{
      break;
    }
  }
  return res;
}

// ??¬??§?????°????????????
int factor(SC& begin){
  if (*begin == '('){
    begin++;
    int res = expression(begin);
    begin++;
  }
  else{
    return number(begin);
  }
}

int main() {
	int n;
	cin >> n;
	string s;
	REP(i,n){
		cin >> s;
		SC begin = s.begin();
		cout << expression(begin) << endl;
	}
	return 0;
}

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

int k,n,ans;
string s;

int calc1();
int calc2();
int calc3();

int calc1(){
	int a;
	a=calc2();
	while(s[k]=='+' ||s[k]=='-'){
		if(s[k]=='+'){
			k++;
			a+=calc2();
		}else if(s[k]=='-'){
			k++;
			a-=calc2();
		}
	}
	return a;
}

int calc2(){
	int a;
	a=calc3();
	while(s[k]=='*' ||s[k]=='/'){
		if(s[k]=='*'){
			k++;
			a*=calc3();
		}else if(s[k]=='/'){
			k++;
			a/=calc3();
		}
	}
	return a;
}

int calc3(){
	int a;
	if(s[k]=='('){
		k++;
		a=calc1();
		k++;
	}else{
		a=0;
		while(s[k]>='0' && s[k]<='9'){
			a*=10;
			a+=s[k]-'0';
			k++;
		}
	}
	return a;
}

int main(){
	cin >> n;
	while(n--){
		ans=0;
		k=0;
		cin >> s;
		ans=calc1();
		cout << ans <<endl;
		s.clear();
	}
	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 = Elem();
    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;
  }
}

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