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 <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)

void calc(string st, stack<ll> &s) {	
	if(st == "*") {
		int a = s.top();
		s.pop();
		int b = s.top();
		s.pop();
		s.push(a * b);
	} else if(st == "+") {
		int a = s.top();
		s.pop();
		int b = s.top();
		s.pop();
		s.push(a + b);
	} else if(st == "-") {
		int a = s.top();
		s.pop();
		int b = s.top();
		s.pop();
		s.push(b - a);
	} else if(st == "/") {
		int a = s.top();
		s.pop();
		int b = s.top();
		s.pop();
		s.push(b / a);
	} else {
		s.push(atoi(st.c_str()));
	}
}
int getPriority(string s) {
	// ?????????
	if(s == "(") {
		return 5;
	} else if(s == "*" || s == "/") {
		return 3;
	} else if(s == "+" || s == "-") {
		return 2;
	} else if(s == ")") { 
		return 1;
	} else return 4;
}

int main() {
	int n;
	cin >> n;
	while(n--) {
		string str;
		cin >> str;
		str.erase(--str.end());
		
		vector<string> v;
		
		int f = 0;
		rep(i, str.size()) {			
			if(isdigit(str[i])) {
				f++;
			} else {
				if(f) {
					string st;
					rep(j,f) {
						st += str[i - f + j];
					}
					v.push_back(st);
					string st2;
					st2 += str[i];
					v.push_back(st2);
					f = 0;
				} else {
					string st3;
					st3 += str[i];
					v.push_back(st3);
				}
			}
		}
		stack<string> s;
		vector<string> nv;
		stack<ll> ret;
		int p = 0;
		rep(i,v.size()) {
			p = getPriority(v[i]);
			while(!s.empty() && getPriority(s.top()) > p && s.top() != "(") {
				nv.push_back(s.top());
				s.pop();
			}
			if(v[i] == ")") {
				s.pop();
			} else {
				s.push(v[i]);
			}
		}
		while(!s.empty()) {
			nv.push_back(s.top());
			s.pop();
		}
		rep(i,nv.size()) {
			calc(nv[i], ret);
			rep(j,ret.size())
				cout << ret.top() << endl;
			cout << endl;
		}
		cout << ret.top() << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


typedef long long ll;


int lp;
int lpcnt = 0;


string str;

bool input(){

  if(lpcnt==0)cin>>lp;

  if(lpcnt==lp)return false;
  cin>>str;

  lpcnt++;
  return true;
}


class S{
public:
  bool isnum;
  bool isc;
  char c;
  int num;
  S(bool isnum, bool isc, char c, int num):isnum(isnum),isc(isc),c(c),num(num){}
  S(){isnum=isc=false; c='#'; num=0;}
  void print(){
    printf("%d %d %d %c\n",isnum,isc,num,c);
  }
};

typedef pair<int,string> pis;
typedef pair<char,string> pcs;

bool isnum(char c){
  return '0'<=c && c<='9';
}

int ctonum(char c){
  return c-'0';
}

pis getHeadNum(string str){

  pis ret = pis(0,"");
  int st = 0;
  while(str.size()!=st && isnum(str[st])){
    ret.first *= 10;
    ret.first += ctonum(str[st]);
    st++;
  }

  ret.second = str.substr(st);
  return ret;
}

pcs getHeadChar(string str){
  return pcs(str[0], str.substr(1));
}

bool iscalc(char c){
  if(c=='*' || c=='+' || c=='-' || c=='/')return true;
  return false;
}


vector<S> getEq(string str){
  vector<S> eq;
  string sc = str;
  eq.clear();

  while(sc.size()!=0){
    int hu = 1;
    S add;
    if(sc[0]=='-' && ((eq.size()!=0 && iscalc(eq[eq.size()-1].c))||eq.size()==0)){
      hu = -1;
      sc = sc.substr(1);
    }
    if(isnum(sc[0])){
      add.isnum = true;
      pis res = getHeadNum(sc);
      add.num = hu*res.first;
      sc = res.second;
    }else{
      add.isc = true;
      pcs res = getHeadChar(sc);
      add.c = res.first;
      sc = res.second;
    }
    eq.push_back(add);
  }
  return eq;
}

int calc(int st, int en, vector<S>& eq){
  
  
  /*
  for(int i=st;i<en;i++){
    eq[i].print();
  }puts("");
  */



  if(st>=en){
    printf("%d %d\n",st,en);
    assert(0);
  }

  int num = eq[st].num;
  if(st+1==en)return num;
  int a=0;

  for(int i=en-1;i>=st;i--){

    if(eq[i].c=='(')a++;
    if(eq[i].c==')')a--;


    if(a==0){
      if(eq[i].c=='-'){
	return calc(st, i, eq) - calc(i+1, en, eq);
      }
      if(eq[i].c=='+'){
	return calc(st, i, eq) + calc(i+1, en, eq);
      }
    }

  }

  a=0;

  for(int i=en-1;i>=st;i--){

    if(eq[i].c=='(')a++;
    if(eq[i].c==')')a--;
    if(a==0){
      if(eq[i].c=='*'){
	return calc(st, i, eq) * calc(i+1, en, eq);
      }
      if(eq[i].c=='/'){
	return calc(st, i, eq) / calc(i+1, en, eq);
      }
    }

  }

  if(eq[st].c=='('){
    return calc(st+1, en-1, eq);
  }
  puts("AAA");
  assert(0);
  return -1;
  
}
int solve(){
  vector<S> eq = getEq(str);
  return calc(0,eq.size()-1, eq);
}

int main(){
  while(input()){
    cout<<solve()<<endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

/*
<expression> ::= <term> | <term> ('+' | '-') <term>
<term> ::= <factor> | <factor> ('*' | '/') <factor>
<factor> ::= <number> | '(' <expression> ')'
<number> ::= 0~9 | <number> <number>
*/
int expression(string &s,int &i);
int term(string &s,int &i);
int factor(string &s,int &i);
int number(string &s,int &i);

int expression(string &s,int &i) {
    int ret=term(s,i);
    while(s[i]=='+' || s[i]=='-') {
        char op=s[i++];
        int right=term(s,i);
        if(op=='+') ret+=right;
        else ret-=right;
    }
    return ret;
}
int term(string &s,int &i) {
    int ret=factor(s,i);
    while(s[i]=='*' || s[i]=='/') {
        char op=s[i++];
        int right=factor(s,i);
        if(op=='*') ret*=right;
        else ret/=right;
    }
    return ret;
}
int factor(string &s,int &i) {
    if(s[i]=='(') {
        i++;
        int expr=expression(s,i);
        i++;
        return expr;
    } else {
        return number(s,i);
    }
}
int number(string &s,int &i) {
    int num=0;
    while('0'<=s[i] && s[i]<='9') {
        num*=10;
        num+=s[i]-'0';
        i++;
    }
    return num;
}

int solve() {
    string s=IN;
    int i=0;
    return expression(s,i);
}
signed main() {
    int n=IN;
    while(n--) {
        cout<<solve()<<endl;
    }
    return 0;
}