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<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
typedef string::const_iterator State;
Def expr(string& s,State &i);
Def term(string& s,State &i);
Def factor(string& s,State &i);
Def number(string& s,State &i);
void consume(State &i,char expected){
	if(*i==expected)i++;
	else{
		exit(0);
	}
}
Def expr(string& s,State &i){
	Def out=term(s,i);
	while(*i=='+'||*i=='-'){
		char op=*i;
		i++;
		Def out1=term(s,i);
		if(op=='+')out+=out1;
		else out-=out1;
	}
	return out;
}
Def term(string& s,State &i){
	Def out=factor(s,i);
	while(*i=='*'||*i=='/'){
		char op=*i;
		i++;
		Def out1=factor(s,i);
		if(op=='*')out*=out1;
		else out/=out1;
	}
	return out;
}
Def factor(string& s,State &i){
	if(isdigit(*i))return number(s,i);
	//'('
	i++;
	Def out=expr(s,i);
	i++;
	return out;
}
Def number(string& s,State &i){
	Def out=0;
	while(isdigit(*i))out=out*10+*(i++)-'0';
	return out;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		cout<<expr(s,s.begin())<<endl;
	}
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define for(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define mp make_pair
#define x first
#define y second

using namespace std;

static const double eps = 1e-9;

typedef pair<int, int> p;
typedef long long ll;

template<class t>
inline t sq(t a){return a*a;}

int expr();
int term();
int num();

//式 ::= 項 | 項+式 | 項-式
//項 ::= (式) | 因子*項 | 因子/項
//因子 ::= 数字
string s;
int ptr;
int expr(){
	int x = term();
	if(s[ptr] == '+'){
		ptr++;
		x += expr();
	}else if(s[ptr] == '-'){
		ptr++;
		x -= expr();
	}
	return x;
}

int term(){
	int x;
	if(s[ptr] == '('){
		ptr++;
		x = expr();
		ptr++;
	}else{
		x = num();
		if(s[ptr] == '*'){
			ptr++;
			x *= term();
		}
		else if(s[ptr] == '/'){
			ptr++;
			x/= term();
		}
	}
	return x;
}

int num(){
	int x = 0;
	int y = 1;
	if(s[ptr] == '-'){
		y = -1;
		ptr++;
	}
	while('0' <= s[ptr] && s[ptr] <= '9'){
		x *= 10;
		x += (s[ptr]-'0');
		ptr++;
	}
	return x*y;
}


int main(){
	int n;
	cin >> n;
	while(n--){
		cin >> s;
		ptr = 0;
		cout << expr() << endl;
	}

	return 0;
}

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

typedef string::const_iterator State;
class ParseError {};

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

int main(void) {
    int N;
    cin >> N;
    cin.ignore();
    for (int i = 0; i < N; i++) {
        string s;
        getline(cin, s);

        State begin = s.begin();
        int ans = expression(begin);
        cout << ans << endl;
    }

    return 0;
}

int expression(State &begin) {
    int ret = (term(begin));

    while (1) {
        if (*begin == '+') {
            begin++;
            ret += term(begin);
        } else if (*begin == '-') {
            begin++;
            ret -= term(begin);
        } else {
            break;
        }
    }

    return ret;
}

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

    while (1) {
        if (*begin == '*') {
            begin++;
            ret *= factor(begin);
        } else if (*begin == '/') {
            begin++;
            ret /= factor(begin);
        } else {
            break;
        }
    }

    return ret;
}

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;
    }

    return number(begin);
}

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

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

bool is_digit(char c){return '0' <= c && c <= '9';}
string i2s(int i) {
  stringstream ss;
  ss << i;
  return ss.str();
}

string parse(int i, string s) {
  //cout<<s<<endl;
  bool flag = true;
  
  // brace
  if (s.find('(') != -1) {
    // æª©ç`FbNµÄA')'Éoï¤êÆ
    // »¤ÅÈ¢êÉª¯é
    bool mode = true;
    REP(j,s.find('(')+1, s.size()) {
      if (s[j] == ')') break;
      if (s[j] == '(') {
        mode = false;
        break;
      }
    }
    // ÊÌÊuðæ¾·é
    int lbr = s.find('('), rbr;
    if (mode) {
      rbr = s.find(')');
    } else {
      for(int j=s.size()-1;j>=0;j--) if (s[j] == ')') {
        rbr = j; break;
      }
    }
    // ÊàÌvZðæÉs¤½ßÉssð¾é
    string inner = parse(0, s.substr(lbr+1, rbr-lbr-1));
    // ÊàðÁ·é
    s.erase(lbr, rbr-lbr+1);
    s.insert(lbr, inner);
    return parse(0, s);
  }
  
  rep(i,s.size()) if (s[i] == '*' || s[i] == '/') {
    int lhs, rhs, res;
    int li = i-1, ri = i+1;
    while (is_digit(s[li]) && li >= 0) li--;
    while (is_digit(s[ri]) && ri < s.size()) ri++;
    lhs = atoi(s.substr(li+1, i-1-li).c_str());
    rhs = atoi(s.substr(i+1, ri-1-i).c_str());
    if (s[i] == '*') {
      res = lhs * rhs;
    } else {
      res = lhs / rhs;
    }
    s.erase(li+1, ri-li-1);
    s.insert(li+1, i2s(res));
    flag = false;
    return parse(0, s);
  }
  
  rep(i,s.size()) if (s[i] == '+' || s[i] == '-') {
    if (s[i] == '-' && i == 0) continue; 
    int lhs, rhs, res;
    int li = i-1, ri = i+1;
    while (is_digit(s[li]) && li >= 0) li--;
    while (is_digit(s[ri]) && ri < s.size()) ri++;
    lhs = atoi(s.substr(li+1, i-1-li).c_str());
    rhs = atoi(s.substr(i+1, ri-1-i).c_str());
    if (s[i] == '+') {
      res = lhs + rhs;
    } else {
      res = lhs - rhs;
    }
    s.erase(li+1, ri-li-1);
    s.insert(li+1, i2s(res));
    flag = false;
    return parse(0, s);
  }
  
  return s;
}

void solve() {
  string s; cin>>s;
  s = s.substr(0, s.size()-1);
  cout<<parse(0, s)<<endl;
}

int main (int argc, char const* argv[]) {
  int n; cin>>n;
  rep(i,n) solve();
  return 0;
}