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 <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
int expr(string& s, int& i);
int number(string& s, int& i){
	int val=0;
	do {
	val*=10;
	val += s[i] - '0';
	i++;
	} while ('0'<=s[i]&&s[i]<='9');
return val;
}
int factor(string& s, int& i){
	if (s[i] >= '0'&&s[i] <= '9')return number(s, i);

	i++;
	int val = expr(s, i);
	i++;
	return val;

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

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


int main() {
	int n;
	cin >> n;
	while (n--){
		string s;
		cin >> s;
		int i = 0;
		if (s[s.length()-1]=='=')
			s=s.substr(0,s.length()-1);
		cout << expr(s, i) << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<cctype>
using namespace std;
string s;
long id;
long ev1(void);
long num(void){
long v=0;
while(isdigit(s[id])){v=v*10+(s[id]-48);id++;}
return v;
}
long ev3(void){
if(s[id]=='('){
id++;
long v=ev1();
id++;
return v;
}else return num();
}
long ev2(void){
long v=ev3();
while(1){
if(s[id]=='*'){id++;v*=ev3();}
else if(s[id]=='/'){id++;v/=ev3();}
else break;
}
return v;
}
long ev1(void){
long v=ev2();
while(1){
if(s[id]=='+'){id++;v+=ev2();}
else if(s[id]=='-'){id++;v-=ev2();}
else break;
}
return v;
}
int main(){
long n,i;
cin>>n;
for(i=0;i<n;i++){
cin>>s;
id=0;
cout<<ev1()<<endl;
}
return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

//<expr>   :: = <term>[('+' | '-') <term>] *
//<term>   :: = <factor>[('*' | '/') <factor>] *
//<factor> :: = <number> | '(' <expr> ')'
//<number> : == 1?????\????????°???


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

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

ll factor(string& s, ll& i) {
	if (isdigit(s[i])) return number(s, i);

	// ????????§?§?????????£???????????° s[i] == '(' ??¨??????
	i++; // '('??????????£???°???
	ll ret = expr(s, i);
	i++; // ')'??????????£???°???
	return ret;
}

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

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

int n;
ll pos = 0;
string s;

int main() {
	cin >> n;
	REP(i,2){
		cin >> s;
		pos = 0;
		cout << expr(s, pos) << endl;
	}
}

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

using namespace std;

typedef string::iterator si;

int expr(si& cur, si end);

int num(si& cur, si end){
    int ans = 0;
    while(cur != end && isdigit(*cur)){
        ans *= 10;
        ans += *cur-'0';
        cur++;
    }
    return ans;
}

int fact(si& cur, si end){
    int ans = 1;
    if(*cur == '('){
        cur++;
        ans *= expr(cur, end);
        cur++;
    } else {
        ans *= num(cur, end);
    }
    return ans;
}

int term(si& cur, si end){
    int ans = 1;
    char op = '*';
    while(1){
        int f = fact(cur,end);

        if(op == '*') ans *= f;
        else ans /= f;
        if(cur == end || *cur == ')' ||  (*cur != '*' && *cur != '/')) break;
        else op = *cur;
        cur++;
    }
    return ans;
}

int expr(si& cur, si end){
    int ans = 0;
    char op = '+';
    while(1){
        int t = term(cur, end);

        if(op == '+') ans += t;
        else ans -= t;

        if(cur == end || *cur == ')') break;
        else op = *cur;
        cur++;
    }
    return ans;
}




int main(){
    int n; cin>>n;
    while(n--){
        string s; cin>> s;
        si b = s.begin();
        cout << expr(b, s.end()-1) << endl;
    }
}

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

using namespace std;

string str;
int cur = 0;

int expression();
int term();
int factor();

int digit() {
    int a = str[cur] - '0';
    cur++;
    return a;
}

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

int expression() {
    int a = factor();
    while (cur < str.size() && (str[cur] == '+' || str[cur] == '-')) {
        if (str[cur] == '+') {
            cur++;
            int b = factor();
            a += b;
        } else if (str[cur] == '-') {
            cur++;
            int b = factor();
            a -= b;
        }
    }
    return a;
}

int term() {
    int a = number();
    while (cur < str.size() && (str[cur] == '*' || str[cur] == '/')) {
        if (str[cur] == '*') {
            cur++;
            int b = factor();
            a *= b;
        } else if (str[cur] == '/') {
            cur++;
            int b = factor();
            a /= b;
        }
        cur++;
    }
    return a;
}

int factor() {
    if (str[cur] != '(') return term();

    cur++;
    int a = expression();
    cur++;
    return a;
}

int main() {
    int N = 0;
    cin>>N;
    for (int n = 0; n < N; n++) {
        cin>>str;
        cur = 0;
        cout<<expression()<<endl;
    }
}