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++: /*
  参考元：構文解析 Howto
  (https://gist.github.com/draftcode/1357281)

  構文解析
  <四則演算の式> ::= <乗算除算の式> (+ or -) <乗算除算の式> (+ or -) ...
  <乗算除算の式> ::= <括弧か数> (* or / ) <括弧か数> (* or / ) ...
  <括弧か数> ::= '(' <四則演算の式> ')' or <数>
  <数> ::= ...
*/

#include <iostream>
#include <string>
#include <cctype>

using namespace std;

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

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


// 数字の列をパースして，その数を返す．
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;
    }
    else
        return number(begin);
}

// 乗算除算の式をパースして，その評価結果を返す．
int term(State &begin)
{
    int ret = factor(begin);

    while (true) {
        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);

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

    return ret;
}


int main()
{
    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;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
using namespace std;
string str;
int pos;

int exp(void);
int term(void);
int factor(void);

int main(){
  int i,j,n,ans;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> str;
    str.erase(str.size()-1);
    pos = 0;
    ans = exp();
    cout << ans << endl;
    str.clear();
  }
  return 0;
}

int exp(void){
  int x = term();
  while(str[pos] == '+' || str[pos] == '-'){
    char op = str[pos++];
    if(op == '+') x += term();
    else if(op == '-') x -= term();
  }
  return x;
}

int term(void){
  int x = factor();
  while(str[pos] == '*' || str[pos] == '/'){
    char op = str[pos++];
    if(op == '*') x *= factor();
    else if(op == '/') x /= factor();
  }
  return x;
}

int factor(void){
  int x=0,c;
  if(str[pos] == '('){
    pos++;
    x = exp();
    pos++;
  }
  else{
    while(str[pos] >= '0' && str[pos] <= '9'){
      x *= 10;
      x += str[pos++] - '0';
    }
  }
  return x;
}

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 fact();

string s;
int ptr;
int expr(){
	int x = term();
	while(s[ptr] == '+' || s[ptr] == '-'){
		if(s[ptr] == '+'){
			ptr++;
			x += term();
		}else{
			ptr++;
			x -= term();
		}
	}
	return x;
}

int term(){
	int x;
	x = fact();
	while(s[ptr] == '*' || s[ptr] == '/'){
		if(s[ptr] == '*'){
			ptr++;
			x *= fact();
		}
		else if(s[ptr] == '/'){
			ptr++;
			x/= fact();
		}
	}

	return x;
}

int fact(){
	int x = 0, y = 1;
	if(s[ptr] == '+') ptr++;
	if(s[ptr] == '-'){
		y = -1;
		ptr++;
	}
	if(s[ptr] == '('){
		ptr++;
		x = expr();
		ptr++;
	}else{
		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;
}