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 <string>
using namespace std;

int weak(string& s, int& i);
int strong(string& s, int& i);
int fc(string& s, int& i);
int inte(string& s, int& i);

int weak(string& s, int& i) {
	int buf = strong(s, i);
	while (s[i] == '+' || s[i] == '-') {
		if (s[i] == '+') {
			i++;
			buf += strong(s, i);
		}
		else {
			i++;
			buf -= strong(s, i);
		}
	}
	return buf;
}

int strong(string& s, int& i) {
	int buf = fc(s, i);
	while (s[i] == '*' || s[i] == '/') {
		if (s[i] == '*') {
			i++;
			buf *= fc(s, i);
		}
		else {
			i++;
			buf /= fc(s, i);
		}
	}
	return buf;
}

int fc(string& s, int& i) {
	if ('0' <= s[i] && '9' >= s[i])return inte(s, i);
	else {
		i++;
		int re = weak(s, i);
		i++;
		return re;
	}
}

int inte(string& s, int& i) {
	int buf = s[i] - '0';
	i++;
	while ('0' <= s[i] && '9' >= s[i]) {
		buf = buf * 10 + s[i] - '0';
		i++;
	}
	return buf;
}

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

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

int Num();
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 Term() {
	int res = Num();
	while (true) {
		if (s[ite] == '*') {
			ite++;
			if (s[ite] == '(') {
				ite++;
				res *= Exp();
				assert(s[ite] == ')');
				ite++;
			}
			else {
				res *= Num();
			}
		}
		else if (s[ite] == '/') {
			ite++;
			if (s[ite] == '(') {
				ite++;
				res /= Exp();
				assert(s[ite] == ')');
				ite++;
			}
			else {
				res /= Num();
			}
		}
		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();
		}
		else {
			cout << "abyaaaa" << endl;
			assert(false);
		}
	}
	return res;
}

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

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <functional>
#include <numeric>
using namespace std;
#define rep(p,q) for(int i = p;i < q; i++)
#define big (long long int)(10e9 + 7)

int siki(string &str, int &i);
int kou(string &str, int &i);
int insu(string &str, int &i);
int number(string &str, int &i);

int main(void) {
	int num = 0;
	cin >> num;
	rep(0, num) {
		string str;
		int x = 0;
		cin >> str;
		cout << siki(str, x);
	}
}

int siki(string &str,int &i) {
	int val1 = kou(str,i);
	if (str[i] == '+' || str[i] == '-') {
		char op = str[i];
		i++;
		int val2 = kou(str, i);
		if (op == '+') {
			val1 = val1 + val2;
		}
		else
		{
			val1 = val1 - val2;
		}
	}
	return val1;
}

int kou(string &str, int &i) {
	int val1 = insu(str, i);
	if (str[i] == '*' || str[i] == '/') {
		char op = str[i];
		i++;
		int val2 = insu(str, i);
		if (op == '*') {
			val1 = val1 * val2;
		}
		else {
			val1 = val1 / val2;
		}
	}
	return val1;
}

int insu(string &str, int &i) {
	int val1 = 0;
	if (str[i] == '(') {
		 val1 = siki(str, i);
		i += 2;
	}
	else {
		 val1 = number(str, i);
	}
	return val1;
}

int number(string &str, int &i) {
	int val1 = 0;
	if (str[i] == '0' || str[i] == '1' || str[i] == '2' || str[i] == '3' || str[i] == '4' || str[i] == '5' || str[i] == '6' || str[i] == '7' || str[i] == '8' || str[i] == '9') {
			 val1 = (int)str[i] - (int)'0';
		i++;
		if (str[i] == '0' || str[i] == '1' || str[i] == '2' || str[i] == '3' || str[i] == '4' || str[i] == '5' || str[i] == '6' || str[i] == '7' || str[i] == '8' || str[i] == '9') {
			val1 = val1 * 10;
			val1 += number(str, i);
		}
	}
	return val1;
}

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] == ')');
	}
	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)trunk(1.0*t/b);
	}
	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++: //https://gist.github.com/draftcode/1357281
#include <string>
#include <cctype>
#include <iostream>
typedef std::string::iterator State;
class ParseError {};

int number(State &begin);
int factor(State &begin);
int term(State &begin);
int expression(State &begin);
void consume(State &begin, char expected){
	if(*begin == expected){
		begin++;
	}else{
		std::cerr << "Expected '" << expected << "' but got '"<<*begin << "'"<<std::endl;
		std::cerr << "Rest string is '";
		while(*begin){
			std::cerr << *begin++;
		}
		std::cerr<<"'"<<std::endl;
		throw ParseError();
	}
}

int main(void){
	int N;
	std::cin >> N;
	//std::cin.ignore();
	while(N--){
		std::string s;
		std::getline(std::cin, s);
		State begin = s.begin();
		int ans = expression(begin);
		consume(begin, '=');
		std::cout << ans << std::endl;
	}
	return 0;
}

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

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

	return ret;
}

int factor(State &begin){
	if(*begin == '('){
		consume(begin,'(');
		int ret = expression(begin);
		consume(begin,')');
	}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;
}

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

using namespace std;

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

int now;
string s;

int expression(){
	int res=term();
		while(true){
		if(s[now]=='+')now++,res+=term();
		else if(s[now]=='-')now++,res-=term();
		else break;
	}
	return res;
}

int term(){
	int res=factor();
	while(true){
		if(s[now]=='(')res+=factor();
		else if(s[now]=='*')now++,res*=factor();
		else if(s[now]=='/')now++,res/=factor();
		else break;
	}
	return res;
}

int factor(){
	int res=0;
	if(s[now]=='(')now++,res=expression(),now++;
	else return number();
	return res;
}

int number(){
	int res=0;
	while('0'<=s[now] && s[now]<='9')res*=10,res+=s[now++]-'0';
	return res;
}


int main(void){
	int n;
	cin >> n;
	
	while(n--){
		cin >> s;
		now=0;
		cout << expression() << endl;
	}
	
	return 0;
}