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>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int number(State &begin);
int expression(State &begin);
int factor(State &begin);
int term(State &begin);
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(1){
        if(*begin == '*'){
            begin++;
            ret *=  factor(begin);
        }else if(*begin == '/'){
            begin++;
            ret /= number(begin);
        }else{
            break;
        }
    }
    return ret;
}
int expression(State &begin){
    int ret = term(begin);
    while(1){
        if(*begin == '+'){
            begin++;
            ret += term(begin);
        }else if(*begin == '-'){
            begin++;
            ret -= term(begin);
        }else{
            break;
        }
    }
    return ret;
}
int factor(State &begin){
    if(*begin == '('){
        begin++;
        int ret = expression(begin);
        begin++;
    }else{
        return number(begin);
    }
}
int main(){
    string s;
    CIN(N);
    REP(a,N){
        cin >> s;
        State w = s.begin();
        COUT(expression(w));
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <cctype>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<long long>
#define vvl vector<vector<long long>>

using namespace std;

typedef long long ll;
typedef string::const_iterator State;

// <四則演算の式>をパース
int expression(State &);
// <乗算除算の式>をパース
int term(State &);
// <数>をパース
int number(State &);
// カッコの中
int factor(State &);

int main()
{
  int N;
  cin >> N;
  cin.ignore();
  REP(i, N)
  {
    string s;
    getline(cin, s);
    size_t pos;
    while ((pos = s.find_first_of(" ")) != string::npos)
    {
      s.erase(pos, 1);
    }
    State begin = s.begin();
    int ans = expression(begin);
    cout << ans << endl;
  }
  return 0;
}

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

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

  return res;
}

int term(State &begin)
{
  int res = factor(begin);

  while (true)
  {
    switch (*begin)
    {
    case '*':
      begin++;
      res *= factor(begin);
      break;
    case '/':
      begin++;
      res /= factor(begin);
      break;
    default:
      return res;
    }
  }
}

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

  while (true)
  {
    switch (*begin)
    {
    case '+':
      begin++;
      res += term(begin);
      break;
    case '-':
      begin++;
      res -= term(begin);
      break;
    default:
      return res;
    }
  }
}

int factor(State &begin)
{
  if (*begin == '(')
  {
    begin++;
    int res = expression(begin);
    begin++;
    return res;
  }
  else
  {
    return number(begin);
  }
}

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

typedef string::const_iterator State;
int number(State &begin);
int factor(State &begin);
int expression(State &begin);
int term(State &begin);

int number(State &begin){		//数字
	int ret = 0;
	while (isdigit(*begin)){
		ret *= 10;
		ret += (*begin - '0');
		begin++;
	}
	return ret;
}
int factor(State &begin){		//括弧
	if (*begin == '(') return expression(begin);
	if (*begin == '-') return -1 * factor(begin);
	if (*begin == '+') return factor(begin);
	
	int ret = number(begin);
	begin--;
	return ret;
}
int term(State &begin){			//乗算除算
	int ret = factor(begin);
	while (1){
		if (*begin == '*') ret *= factor(++begin);
		else if (*begin == '/') ret /= factor(++begin);
		else break;
	}
	begin--;
	return ret;
}
int expression(State &begin){	//四則演算
	int ret = term(begin);
	while (1){
		if (*begin == '+') ret += term(++begin);
		else if (*begin == '-') ret -= term(++begin);
		else break;
	}
	return ret;
}

int main(void)
{
	int n;
	cin >> n;
	cin.ignore();
	for (int i = 0; i < n; i++){
		string str;
		getline(cin, str);
		
		State begin = str.begin();
		cout << expression(begin) << endl;
	}
	
	return 0;
}

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

typedef long long ll;

string s;

ll stol(string str){
  stringstream ss(str);
  ll n;
  ss >> n;
  return n;
}

ll parse(int l, int r){
  int num = 0, i;
  for(int i=r-1;i>=l;i--){
    if(s[i] == ')')n++;
    if(s[i] == '(')n--;
    if(!n){
      if(s[i] == '+')return parse(l,i) + parse(i+1,r);
      if(s[i] == '-')return parse(l,i) - parse(i+1,r);
    }
  }
  for(int i=r-1;i>=l;i--){
    if(s[i] == ')')n++;
    if(s[i] == '(')n--;
    if(!n){
      if(s[i] == '*')return parse(l,i) * parse(i+1,r);
      if(s[i] == '/')return parse(l,i) / parse(i+1,r);
    }
  }

  if(s[l] == '(' && s[r-1] == ')')return parse(l+1,r-1);
  return stol( s.substr(l,r-l) );
}

int main(){
  int n;
  cin >> n;
  while(n--){
    cin >> s;
    cout << parse(0,(int)s.size()-1) << endl;
  }
}

C++:  #include<iostream>
 #include<string>
 
 using namespace std;
 
 int expression();
 int term();
 int factor();
 
 string exp;
 int p;
 
 int expression(){
     int value = term();
    while( exp[p] == '+' || exp[p] == '-' ){
        if ( exp[p] == '+' ) { p++; value += term(); }
        else { p++; value -= term(); }
     }
     return value;
 }
 
 int term(){
     int 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] == '(' ){
         p++; value = expression(); p++;
     } else {
         while( isdigit(exp[p]) ) { value = value*10 + exp[p++] - '0';}
     }
     return value;
 }
 
 int main(){
     int tcase; cin >> tcase;
     for ( int i = 0; i < tcase; i++ ){
         cin >> exp;
         p = 0;
         cout << expression() << endl;
     }
     return 0;
 }