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>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>




#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;

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

int expr(string& s, int& i) {
	int 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 term(string &s, int &i) {
	int 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;
}

int factor(string &s, int &i) {
	if (isdigit(s[i]))return number(s, i);
	i++;
	int ret = expr(s, i);
	i++;
	return ret;
}

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

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	REP(i, N) {
		string str;
		cin >> str;
		int j = 0;
		print(expr(str, j));
	}
}

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

int p;
string str;

int Term();
int Factor();
int Elem();
int Digit();

int Term() {
  int a = Factor();
  while (str[p] == '+' || str[p] == '-') {
    char c = str[p];
    p++; // read [+-]
    int b = Factor();
    if (c == '+') {
      a = a + b;
    } else {
      a = a - b;
    }
  }
  return a;
}

int Factor() {
  int a = Elem();
  while (str[p] == '*' || str[p] == '/') {
    char c = str[p];
    p++; // read [*/]
    int b = Elem();
    if (c == '*') {
      a = a * b;
    } else {
      a = a / b;
    }
  }
  return a;
}

int Elem() {
  if (str[p] == '(') {
    p++; // read (
    int a = Term();
    p++; // read )
    return a;
  } else {
    int a = 0;
    while (isdigit(str[p])) {
      int b = Digit();
      a = 10 * a + b;
    }
    return a;
  }
}

int Digit() {
  int a = str[p] - '0';
  p++; // read [0-9]
  return a;
};

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> str;
    p = 0;
    cout << Term() << endl;
  }
}

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

typedef pair<int, int> result;
#define value first
#define p second

result equation(const string &s, int p = 0);
result factor(const string &s, int p = 0);
result term(const string &s, int p = 0);

result equation(const string &s, int p) {
	result r = factor(s, p);
	while( s[r.p] == '+' || s[r.p] == '-' ){
		result r_ = factor(s, r.p+1);
		if( s[r.p] == '+' )
			r.value += r_.value;
		else
			r.value -= r_.value;
		r.p = r_.p;
	}
	return r;
}

result factor(const string &s, int p) {
	result r = term(s, p);
	while( s[r.p] == '*' || s[r.p] == '/' ) {
		result r_ = term(s, r.p+1);
		if( s[r.p] == '*' )
			r.value *= r_.value;
		else
			r.value /= r_.value;
		r.p = r_.p;
	}
	return r;
}

result term(const string &s, int p) {
	if( s[p] == '(' ) {
		result r = equation(s, p+1);
		r.p += 1; // skip ')'
		return r;
	}else{
		int value = 0;
		while ( isdigit(s[p]) )
			value = value * 10 + (s[p++] - '0');
		return result(value, p);
	}
}

int main() {
	string s;
	int n;
	cin >> n;
	for(int i=0 ; i < n ; i++ ){
		cin >> s;
		result r = equation( s );
		cout << r.value << endl;
	}
}

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

typedef pair<int,char> P;

int calc(int a, int b, char ope) {
	int ret;
	switch(ope) {
	case '+': ret = a + b; break;
	case '-': ret = a - b; break;
	case '*': ret = a * b; break;
	case '/': ret = a / b; break;
	default: ret = 0;
	}
	return ret;
}

int main() {
	int n, v, sv; string s; char c, ope, sope;
	stack<P> st;
	cin >> n;
	while(n--) {
		cin >> s; v = 0; ope = '#';
		for(int i=0; i<(signed)s.length(); ++i) {
			c = s[i];
			if('0'<=c && c<='9') {
				
				v = v*10+(int)(c-'0');
			}else if(c=='('){
				st.push(P(0,'#'));
				v = 0;
			}else if(c==')'){
				while(!st.empty()) {
					sv=st.top().first; sope=st.top().second; st.pop();
					if(sope=='#') break;
					v = calc(sv, v, sope);
				}
			}else {
				if(c=='=') break;
				ope = c;
				if(st.empty()) {
					st.push(P(v,ope)); v=0;
				}else {
					sv=st.top().first; sope=st.top().second;
					if(((sope=='+'||sope=='-')&&(ope=='*'||ope=='/'))||sope=='#') {
						st.push(P(v,ope)); v=0;
					}else {
						v = calc(sv, v, sope);
						st.pop();
						st.push(P(v,ope));
						v=0;
					}
				}
			}
		}
		while(!st.empty()) {
			sv=st.top().first; sope=st.top().second; st.pop();
			v = calc(sv, v, sope);
		}
		cout << v << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int n;
string str;
int start,goal;
void kake();
void tasi();
void tume(int s,int g){
  string str2="";
  for(int i = 0 ; i < str.size() ; i++){
    if(str[i] != '#'&& (s!=i || g != i))str2+=str[i];
  }
  str= str2;
}
void cal(){
  kake();
  tasi();
}
void kake(){
  for(int i = start ; i <= goal ; i++ ){
    if(str[i] == '*'){
      int t = (str[i-1] - '0')*(str[i+1] - '0'); 

      str[i-1] = str[i+1] = '#'; 
      str[i] = char(t+'0');
      tume(i-1,i+1);
      i = start;
      goal = goal-2;

    }
    if(str[i] == '/'){
      int t = (str[i-1] - '0')/(str[i+1] - '0'); 
      str[i-1] = str[i+1] = '#'; 
      str[i] = char(t+'0');
      tume(i-1,i+1);
      i = start;
      goal = goal-2;


    }
  }
}
void tasi(){
  for(int i = start ; i <= goal ; i++ ){
    if(str[i] == '+'){
      int t = (str[i-1] - '0')+(str[i+1] - '0'); 
      str[i-1] = str[i+1] = '#'; 
      str[i] = char(t+'0');
      tume(i-1,i+1);
      i = start;
      goal = goal-2;

    }
    if(str[i] == '-'){
      int t = (str[i-1] - '0')-(str[i+1] - '0'); 
      str[i-1] = str[i+1] = '#'; 
      str[i] = char(t+'0');
      tume(i-1,i+1);
      i = start;
      goal = goal-2;
    }
  }
}

int main(){
  cin >> n;
  while(n--){
    str = "";
    cin >> str;

    if(str[0] == '#')break;

    for(int i = 0 ; i < str.size() ; i++){
      if(str[i] == '(')start = i;
      if(str[i] == ')'){
	goal = i;
	cal();
	str[start] = '#';
	str[goal] = '#';
	tume(start,goal);
	i = -1;
	continue;
      }
    }
    start = 0,goal = str.size()-1;
    cal();
    int ans = str[0] - '0';
    cout << ans << endl;
  }
}