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 <string>
#include <cctype>
#include <iostream>
typedef std::string::iterator State;
using namespace std;

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

int main(void){
  int N;
  std::cin >> N;

  while(N--){
    std::string s;
    std::cin>>s;
    State begin = s.begin();
    int ans = expression(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 == '('){
    begin++;
    int ret = expression(begin);
    begin++;
    return ret;
  }else{
    return number(begin);
  }
}
 

 
int expression(State &begin){
  int num = factor(begin);
  int sum = 0;
  
  for(;;){
    char ch = *begin;
    begin++;
    if(ch == '+'){
      num += factor(begin);
    } else if(ch == '-'){
      num -= factor(begin);
    }else if(ch == '*'){
      sum += num;
      num = factor(begin);
    }else if(ch == '/'){
      sum += num;
      num = factor(begin);
    }else{
      break;
    }
  }
  return sum+num;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

class Parser
{
public:
	string exp;
	int p;
	int expression (void );
	int term (void );
	int factor (void );
private:

};

int Parser::expression (void)
{
	int value = term ();

	while (exp[p] == '+' || exp[p] == '-' ){
		if (exp[p] == '+' ){
			++p; value += term();
		}else{
			++p; value -= term();
		} // end if
	} // end while

	return value;
}

int Parser::term (void)
{
	int value = factor();

	while (exp[p] == '*' || exp[p] == '/' ){
		if (exp[p] == '*'){
			++p; value *= factor();
		}else{
			++p; value /= factor();
		} // end if
	} // end while

	return value;
}

int Parser::factor (void)
{
	int value = 0;

	if (exp[p] == '('){
		++p; value = expression(); ++p;
	}else{
		while (isdigit(exp[p]) ){
			value = value * 10 + exp[p] - '0';
			++p;
		} // end while
	} // end if
	
	return value;
}

int main()
{
//	cut here before submit 
//	freopen("testcase.sc", "r", stdin);

	Parser parser;
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	int i;
	for (i = 0; i < n; ++i){
		getline (cin, str );
		parser.exp = str;
		parser.p = 0;
		cout << parser.expression() << endl;
	} // end loop
		
	return 0;
}

C++: #include <iostream>
#include <stack>

using namespace std;

int pri(char ch) 
{
    if (ch == '*' || ch == '/')
        return 2;
    if (ch == '+' || ch == '-')
        return 1;
    else
        return 0;
}

int main()
{
    int n;

    cin >> n;

    while (n--) {
        string exp, cha;
        stack<char> pol;
        stack<int> cal;

        cin >> exp;
        for (int i = 0; i < exp.size() - 1; i++) {
            if ('0' <= exp[i] && exp[i] <= '9') {
                while (true) {
                    cha.push_back(exp[i]);
                    if ('0' > exp[i + 1] || exp[i + 1] > '9') {
                        cha.push_back('.');
                        break;
                    }
                    else
                        i++;
                }
            }
            else if (exp[i] == '(')
                pol.push(exp[i]);
            else if (exp[i] == ')') {
                while (true) {
                    if (pol.top() == '(') {
                        pol.pop();
                        break;
                    }
                    cha.push_back(pol.top());
                    pol.pop();

                }
            }
            else {
                while (!pol.empty()) {
                    if (pri(exp[i]) < pri(pol.top())) {
                        cha.push_back(pol.top());
                        pol.pop();
                    }
                    else 
                        break;
                }
                pol.push(exp[i]);
            }
        }

        while (!pol.empty()) {
            cha.push_back(pol.top());
            pol.pop();
        }

        cerr << exp << endl;
        cerr << cha << endl;
        for (int i = 0; i < cha.size(); i++) {
            if ('0' <= cha[i] && cha[i] <= '9') {
                int tmp = cha[i] - '0';

                while (true) {
                    i++;
                    if (cha[i] == '.') 
                        break;
                    tmp *= 10;
                    tmp += cha[i] - '0';
                }
                cal.push(tmp);
            }
            else {
                int a, b;

                b = cal.top();
                cal.pop();
                a = cal.top();
                cal.pop();

                if (cha[i] == '*') 
                    cal.push(a * b);
                else if (cha[i] == '/') 
                    cal.push(a / b);
                else if (cha[i] == '+') 
                    cal.push(a + b);
                else if (cha[i] == '-') 
                    cal.push(a - b);
            }
        }
        cout << cal.top() << endl;
    }

    return 0;
}

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

int expr(string& s, int& i);
int term(string& s, int& i);
int factor(string& s, int& i);
int number(string& s, int& i);


int expr(string& s, int& i) {
  int val = term(s, i);
  while(s[i] == '+' || s[i] == '-') {
    char op = s[i];
    i++;
    int val2 = term(s, i);
    if (op == '+') val += val2;
    else val -= val2;
  }
  return val;
}

int term(string& s, int& i) {
  int val = factor(s, i);
  while(s[i] == '*' || s[i] == '/') {
    char op = s[i];
    i++;
    int val2 = factor(s, i);
    if (op == '*') val *= val2;
    else val /= val2;
  }
  return val;
}

int factor(string& s, int& i) {
  if (isdigit(s[i])) return number(s, i);

  // ここで構文が正しければ s[i] == '(' となる
  i++; // '('を読み飛ばす
  int ret = expr(s, i);
  i++; // ')'を読み飛ばす
  return ret;
}

int number(string& s, int& i) {
  int n = s[i++] - '0';
  while(isdigit(s[i])) n = n*10 + s[i++] - '0';
  return n;
}


int main() {
  int n = 0;
  cin >> n;
  string s;
  getline(cin, s);
  for(int i = 0; i < n; i++) {
    getline(cin, s);
    s = s.substr(0, s.size() - 1);
    int i = 0;
    cout << expr(s, i) << endl;
  }
  return 0;
}