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 <math.h>
#include <vector>
#include <set>
#include <stack>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 
int cal(){
  stack<int> st;
  int ope=0;
  int num;
  while(true){
    char c = getchar();
    if(c == '(' || ('0'<=c && c<= '9') ) {
      if(c == '(') num = cal();
      else{
        int dig=0;
        int numd[10]={0};
        numd[0] = (c - '0');
        while(true){
          c = getchar();
          if(!('0'<=c&&c<='9')) break;
          dig++;
          numd[dig] = (c - '0');
        }
        num = 0;
        for(int i=dig; i>=0; i--)
          num+=numd[dig-i] * pow(10,(double)i);
      }
      if(ope==0){
        st.push(num);
      }else if(ope == 1){
        st.push(-num);
        ope = 0;
      }else if(ope == 2){
        int tmp = st.top();
        st.pop();
        st.push(tmp * num);
        ope = 0;
      }else if(ope == 3){
        int tmp = st.top();
        st.pop();
        st.push(tmp / num);
        ope = 0;
      }
    }
    if(c == ')' ) break;
    if(c == '=' ){
      getchar();
      break;
    }
    if(c == '+') ope = 0;
    if(c == '-') ope = 1;
    if(c == '*') ope = 2;
    if(c == '/') ope = 3;
  }
  int sum=0;
  while(!st.empty()){
    sum += st.top();
    st.pop();
  }
  return sum;
}

int main(void){  
  int n;
  cin >> n;
  getchar();
  REP(i,n)
    cout << cal() << 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,'(');
		begin++;
		int ret = expression(begin);
		//consume(begin,')');
		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 <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

using state = string::const_iterator;

int num(state &cur);
int factor(state &cur);
int muldiv(state &cur);
int addsub(state &cur);
int expr(state &cur);

int factor(state &cur) {
    if(isdigit(*cur)) return num(cur);
    cur++;
    int ans = addsub(cur);
    cur++;
    return ans;
}

int num(state &cur) {
    int ans = *cur -'0';
    while(isdigit(*++cur)) ans = ans*10 + (*cur-'0');
    return ans;
}

int muldiv(state &cur) {
    int ans = factor(cur);
    while(true){
        if(*cur == '*'){
            cur++;
            ans *= factor(cur);
        }else if(*cur == '/'){
            cur++;
            ans /= factor(cur);
        }else break;
    }
    return ans;
}

int addsub(state &cur){
    int ans = muldiv(cur);
    while(true){
        if(*cur == '+'){
            cur++;
            ans += muldiv(cur);
        }else if(*cur == '-'){
            cur++;
            ans -= muldiv(cur);
        }else break;
    }
    return ans;
}

int expr(state &cur){
    return addsub(cur);
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        state cur = s.begin();
        cout << expr(cur) << "\n";
    }
    return 0;
}

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

#define rep(i,n) for (int i = 0; i < int(n); i++)
typedef long long ll;

int it, n;
string input;

ll expr();
ll term();
ll fact();

ll expr() {
    int v = term();
    while (input[it] == '+' || input[it] == '-') {
        if (input[it++] == '+') {
            v += term();
        } else {
            v -= term();
        }
    }
    return v;
}

ll term() {
    int v = fact();
    while (input[it] == '*' || input[it] == '/') {
        if (input[it++] == '*') {
            v *= term();
        } else {
            v /= term();
        }
    }
    return v;
}

ll fact() {
    int v = 0;
    if (input[it] == '(') {
        ++it; // '('
        v = expr();
        ++it; // ')'
    } else {
        while ('0' <= input[it] && input[it] <= '9') {
            v = 10*v + input[it]-'0';
            ++it;
        }
    }
    return v;
}

int main() {
    cin >> n;
    rep (i,n) {
        cin >> input;
        it = 0;
        cout << expr() << endl;
    }
}