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 <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef pair<ll,const char*> parsed;

parsed expr(const char*);
parsed term(const char*);
parsed fact(const char*);

parsed expr(const char* s)
{
	parsed now=term(s);
	while(*now.second=='+' || *now.second=='-'){
		char op=*now.second;
		parsed next=term(now.second+1);
		if(op=='+')
			now=parsed(now.first+next.first,next.second);
		else
			now=parsed(now.first-next.first,next.second);
	}
	return now;
}

parsed term(const char* s)
{
	parsed now=fact(s);
	while(*now.second=='*' || *now.second=='/'){
		char op=*now.second;
		parsed next=fact(now.second+1);
		if(op=='*')
			now=parsed(now.first*next.first,next.second);
		else
			now=parsed(now.first/next.first,next.second);
	}
	return now;
}

parsed fact(const char* s)
{
	if(s[0]=='('){
		parsed res=expr(s+1);
		res.second++;
		return res;
	}
	else{
		const char* p=s;
		if(*p=='-')
			p++;
		ll n=0;
		while(isdigit(*p)){
			n=n*10+(*p-'0');
			p++;
		}
		return parsed(n,p);
	}
}

int main()
{
	int n;
	cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		cout<<expr(s.c_str()).first<<endl;
	}
	
	return 0;
}

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

int Num();
int Fact();
int Term();
int Exp();

int ite;
string s;

int Num() {
	int res = 0;
	while (isdigit(s[ite])) {
		res = res * 10 + s[ite] - '0';
		ite++;
	}
	return res;
}

int Fact() {
	if (s[ite] == '(') {
		ite++;
		int res = Exp();
		ite++;
		return res;
	}
	else {
		return Num();
	}
}

int Term() {
	int res = Fact();
	while (true) {
		if (s[ite] == '*') {
			ite++;
			res *= Fact();
		}
		else if (s[ite] == '/') {
			ite++;
			res /= Fact();
		}
		else {
			break;
		}
	}
	return res;
}

int Exp() {
	int res = Term();
	while (s[ite] != '=' && s[ite] != ')') {
		if (s[ite] == '+') {
			ite++;
			res += Term();
		}
		else if(s[ite] == '-') {
			ite++;
			res -= Term();
		}
	}
	return res;
}

int main()
{
	int n;
	cin >> n;
	while (n--) {
		cin >> s;
		ite = 0;
		cout << Exp() << endl;
	}
	return 0;
}

C++: #include <cmath>
#include <cassert>
#include <iostream>

using namespace std;

string S;
size_t cur = 0;

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

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

int expression();
int factor() {
	int n;
	if (S[cur] != '(') n = number();
	else {
		++cur;
		n = expression();
		assert(S[cur] == ')');
		++cur;
	}
	return n;
}

int term() {
	int t = factor();
	while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')) {
		char op = S[cur++];
		int b = factor();
		if(op == '*') t *= b; else t = (int)trunc(1.0*t/b);
		cout << t << endl;
	}
	return t;
}


/*int expression() {
	int sum = number();
	while (S[cur] == '+' || S[cur] == '-') {
		char op = S[cur++];
		int b = number();
		if(op == +) sum += b;	else return sum -= b;
	}
	return sum;
}*/

int expression() {
	int sum = term();
	while (cur < S.size() && (S[cur] == '+' || S[cur] == '-')) {
		char op = S[cur++];
		int b = term();
		if(op == '+') sum += b; else sum -= b;
	}
	return sum;
}


int main() {
	int N;
	cin >> N;
	for (int i=0; i<N; ++i) {
		cur = 0;
		cin >> S;
		S.resize(S.size()-1);
		cout << expression() << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>

#include<cassert>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

string S;
int cur = 0;//?§£???????§???????

int expression();//????????£?¨?

int digit(){
	// assert(isdigit(S[cur]));
	// cout<<"S[cur]="<<S[cur]<<endl;;
	int n = S[cur++] - '0';
	return n;
}

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

int factor(){
	if(S[cur]!='(')return number();
	cur++;
	int n=expression();
	// assert(S[cur++]==')');
	cur++;
	return n;
}

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

int expression() {
	int a = term();
	while (cur<S.size() && (S[cur] == '+' || S[cur] == '-')) { // ?¶???????????????????????¶???????
		char op = S[cur++];
		int b = term();
		if (op == '+')a+=b;else a-=b;
	}
	return a;
}

int main(){
	int N;
	int ans[50];
	cin>>N;
	rep(i,N){
		cur=0;
		cin>>S;
		S.resize(S.size()-1);
		ans[i]=expression();
	}
	rep(i,N)cout<<ans[i]<<endl;
	return 0;
}