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



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 && eq[eq.size()-1].isc)||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);
  }

  if(eq[st].isc){
    int a = 0;

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

      puts("isc");
      assert(0);
    }
  }

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

    reps(i,st+1,en){

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

    }

    reps(i,st+1, en){

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

    puts("isn");
    assert(0);

  }
  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 <iostream>
#include <string>
#include <cctype>
#include <cassert>
#include <cstddef>

using namespace std;


// ?????????????§?????§£???????????????????????¨???????????????
class MathExpress
{
private:
    string m_express;
    size_t m_cur;

public:
    MathExpress(string str) : m_express(str), m_cur(0) 
    {
        m_express.resize(m_express.size() - 1);
    }

    int digit(); // ???????????°???
    int number(); // ??°??????????????°????????´???
    int term();
    int factor(); 
    int expression();
};


int MathExpress::digit()
{
    assert(isdigit(m_express.at(m_cur)));

    int n = m_express.at(m_cur) - '0';

    m_cur += 1;

    //cout << "digit: " << n << endl;

    return n;
}


int MathExpress::number()
{
    int num = digit();

    while ( m_cur < m_express.size() && isdigit(m_express.at(m_cur)) )
    {
        num = num * 10 + digit();
    }

    //cout << "number: " << num << endl;

    return num;
}


int MathExpress::term()
{
    int left = factor();

    while (m_cur < m_express.size() 
         && (m_express.at(m_cur) == '*' || m_express.at(m_cur) == '/'))
    {
        char op = m_express.at(m_cur++);

        //cout << op << endl;

        int right = number();

        switch (op) {
            case '*':
                left *= right;
                break;
            case '/':
                left /= right;
                break;
            default:
                break;
        }

    }

    //cout << "term: " << left << endl;

    return left;
}


int MathExpress::expression()
{
    int left = term();

    while (m_cur < m_express.size() 
         && (m_express.at(m_cur) = '+' || m_express.at(m_cur) == '-'))
    {
        //cout << m_cur << " " << m_express.at(m_cur) << endl;
        char op = m_express.at(m_cur);

        m_cur += 1;

        //cout << op << endl;
        //cout << "hoge" << endl;

        int right = term();

        //cout << "hoge" << endl;

        switch (op) {
            case '+':
                //cout << "hoge" << endl;
                left += right;
                break;
            case '-':
                left -= right;
                break;
            default:
                //cout << "hoge" << endl;
                break;
        }

        //cout << "left : right = " << left << " " << right << endl;
    }

    return left;
}


int MathExpress::factor()
{
    if (m_express.at(m_cur) != '(') return number();

    m_cur += 1;

    int exp = expression();

    assert (m_express.at(m_cur) == ')');

    m_cur += 1;

    return exp;
}


int main()
{
    int data_num;
    
    cin >> data_num;
    
    cin.clear();

    string val; 
    for (int i = 0; i < data_num; ++i) {
        cin >> val;

        MathExpress mathexp(val);
        cout << mathexp.expression() << endl;
    }
    
    return 0;
}