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 <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <numeric>
#include <ctime>
using namespace std;

int number(const string &s, int &k);
int expression(const string &s, int &k);
int term(const string &s, int &k);
int factor(const string &s, int &k);

// 式の評価.
int eval(const string &s){
    int k=0;
    int res = expression(s, k);
    /*if( k != s.size() ){
        // 構文規則が正しくない!!!!
    }*/
    return res;
}

bool is_digit(char c){
	return '0' <= c && c <= '9';
}

// <number> ::= <number> <digit> | <digit>
int number(const string &s, int &k){
    int res = 0;
    while( is_digit(s[k]) ){
        res = res * 10 + (s[k] - '0');
        ++k;
    }
    return res;
}

// <expression(式)> := <expression(式)> + <term(項)> | <term(項)> 
int expression(const string &s, int &k){
    int r1 = term(s, k);
     
    while( k < s.size() ){
        if( s[k] == '+' ){
            ++k;
            int r2 = term(s, k);
            r1 = r1 + r2;
        }else if( s[k] == '-' ){
            ++k;
            int r2 = term(s, k);
            r1 = r1 - r2;
        }else{
            break;
        }
    }
    return r1;
}

// <term(項)> := <term(項)> * <factor(因子)> | <factor(因子)>
int term(const string &s, int &k){
    int r1 = factor(s, k);
     
    while( k < s.size() ){
        if( s[k] == '*' ){
            ++k;
            int r2 = factor(s, k);
            r1 = r1 * r2;
        }else if( s[k] == '/' ){
            ++k;
            int r2 = factor(s, k);
            // 0 除算のエラー
            if( r2 == 0 ){
            	return -1;
            }
            r1 = r1 / r2;
        }else{
            break;
        }
    }
    return r1;
}

// <factor(因子)> := (<expression(式)>) | <Number>
int factor(const string &s, int &k){
    if( s[k] == '(' ){ // 括弧のはじまりのとき
        ++k; // '(' の 1つ先に進める.
        int r = expression(s, k);
        // ')' がないとき
        if( s[k] != ')' ) return -1;
         
        ++k; // ')' の 1つ先に進める.
        return r;
    }else if( is_digit(s[k]) ){ // 数字のとき
        return number(s, k);
    }else{ // 構文エラー
        return -1;
    }
}

int main(){
	int n;
	cin >> n;
	for(int i=0 ; i < n ; i++ ){
		string s;
		cin >> s;
		cout << eval(s) << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int64 exp(string&, int32&);
int64 term(string&, int32&);
int64 fact(string&, int32&);
int64 number(string&, int32&);

int64 exp(string& s, int32& p){
	int64 ret = term(s, p);
	while(p < s.size()){
		if(s[p] == '+'){
			p++;
			ret += term(s, p);
		}else if(s[p] == '-'){
			p++;
			ret -= term(s, p);
		}else{
			break;
		}
	}
	return ret;
}

int64 term(string& s, int32& p){
	int64 ret = number(s, p);
	while(p < s.size()){
		if(s[p] == '*'){
			p++;
			ret *= fact(s, p);
		}else if(s[p] == '/'){
			p++;
			ret /= fact(s, p);
		}else{
			break;
		}
	}
	return ret;
}

int64 fact(string& s, int32& p){
	int64 ret = 0;
	if(s[p] == '('){
		p++;
		ret = exp(s, p);
		p++;
	}else{
		ret = number(s, p);
	}
	return ret;
}

int64 number(string& s, int32& p){
	int64 ret = 0;
	while(isdigit(s[p])){
		ret = ret*10+s[p]-'0';
		p++;
	}
	return ret;
}
int main(void){
	int32 N;
	cin >> N;

	REP(i, N){
		string s;
		int32 p = 0;
		cin >> s;
		cout << exp(s, p) << endl;
	}
}

C++: #include<iostream>
#include<string>

using namespace std;

string S;
size_t cur;

int digit(){
  return S[cur++]-'0';
}

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

int expression();

int factor(){
  if(isdigit(S[cur]))return number();
  cur++;
  int n=expression();
  cur++;
  return n;
}

int term(){
  int t=factor();
  for(;cur<S.size()&&(S[cur]=='*'||S[cur]=='/');){
    if(S[cur++]=='*')t*=factor();
	else t/=factor();
  }
  return t;
}

int expression(){
  int t=term();
  for(;cur<S.size()&&(S[cur]=='+'||S[cur]=='-');){
    if(S[cur++]=='+')t+=term();
	else t-=term();
  }
  return t;
}

int main(){
  int n;
  cin>>n;
  for(;n--;){
    cin>>S;
	cout<<expression()<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
typedef string::const_iterator State;
int expression(State& begin);
int factor(State& begin);
// 乗算除算の式をパースして、その評価結果を返す。
int term(State& begin);
// 数字の列をパースして、その数を返す。
int number(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 == '(') {
        begin++; // '('を飛ばす。
        int ret = expression(begin);
        begin++; // ')'を飛ばす。
        return ret;
    }
    else {
        return number(begin);
    }
}
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 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 main() {
	cin>>n;
	rep(i,n){
    string S;
    cin >> S;
    S=S.substr(0,S.length()-1);
    State s=S.begin();
    cout << expression(s) << endl;
	}
}