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 <vector>
#include <string>
#include <deque>
#include <memory.h>

#define rep(idx, max)			for(int idx = 0, idx##Max = (max); idx < idx##Max; idx ++)
#define rrep(idx, min, max)	for(int idx = (min), idx##Max = max; idx < idx##Max; idx ++)
#define erep(idx, min, max)	for(int idx = (min), idx##Max = max; idx <= idx##Max; idx ++)

#define rev(idx, max)			for(int idx = (max) - 1; idx >= 0; idx --)
#define rrev(idx, min, max)	for(int idx = (max) - 1, idx##Min = (min); idx >= idx##Min; idx --)
#define erev(idx, min, max)	for(int idx = (max), idx##Min = (min); idx >= idx##Min; idx --)

#define foreach(it, obj)	for(auto it = obj.begin(), it##End = obj.end(); it >= it##End; it ++)

using namespace	std;

class CCalc
{
	string	s_;
	int	pos_;
	
	int	IsDigit(int x)	{	return(x <= '9' && x >= '0');	}
	void	SkipSpace()
	{
		cout << "Skipping...";
		for(int c = s_[pos_]; (c == ' ' || c == '\t') && pos_ < s_.size(); pos_ ++);
		cout << "OK" << endl;
	}
	int	Number()
	{
		int num = 0;
		while(IsDigit(s_[pos_]))	{	num	= num * 10 + s_[pos_ ++] - '0';	}
		return(num);
	}
	int	Factor()
	{
		int val;
		if(pos_ >= s_.size())	{	cout << "warning: Out of bounds!" << endl;	}
		if(IsDigit(s_[pos_]))
		{
			val = Number();
			return(val);
		}
		pos_ ++;
		val	= Expr();
		pos_ ++;
		return(val);
	}
	int	Term()
	{
		int	val1	= Factor();
		while(s_[pos_] == '*' || s_[pos_] == '/')
		{
			char	op	= s_[pos_ ++];
			int val2	= Factor();
			switch(op)
			{
				case '*':	val1 *= val2;	break;
				case '/':	val1 /= val2;	break;
			}
		}
		return(val1);
	}
	int	Expr()
	{
		int	val1	= Term();
		while(s_[pos_] == '+' || s_[pos_] == '-')
		{
			char	op	= s_[pos_ ++];
			int val2	= Term();
			switch(op)
			{
				case '+':	val1 += val2;	break;
				case '-':	val1 -= val2;	break;
			}
		}
		return(val1);
	}
	
public:
	int	Eval(string &expression)
	{
		pos_	= 0;
		int pos = 0;
		s_.resize(expression.size());
		rep(i, expression.size())
		{
			if(expression[i] != ' ')
			{	s_[pos ++] = expression[i];	}
		}
		return(Expr());
	}
};

int main()
{
	CCalc	calc;
	string	expression;
	int tc;
	
	for(cin >> tc, cin.ignore(); tc > 0; tc --)
	{
		getline(cin, expression);
		cout << calc.Eval(expression) << endl;
	}
	
//	while(getline(cin, expression), expression.size())
//	{	::printf("%s = %d\n", expression.c_str(), calc.Eval(expression));	}
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<sstream>
#include<algorithm>

std::string find(std::vector<std::string>&v, int a, bool b){

	std::string res;

	if (b){
		for (int i = a - 1; i >= 0; i--){
			if (v[i] != "T"){
				res = v[i];
				v[i] = "T";
				break;
			}
		}
	}

	if (!b){
		for (int i = a + 1; i < v.size(); i++){
			if (v[i] != "T"){
				res = v[i];
				v[i] = "T";
				break;
			}
		}
	}

	return res;
}

int toint(std::string str){

	int res;
	std::stringstream z;

	z << str;
	z >> res;

	return res;

}

std::string tostring(int a){

	std::string str;
	std::stringstream z;

	z << a;
	z >> str;

	return str;

}

std::string keisan(std::string lhs, std::string rhs, int t){

	int a, b, c;

	a = toint(lhs);
	b = toint(rhs);

	if (t == 1)c = a + b;
	if (t == 2)c = a - b;
	if (t == 3)c = a * b;
	if (t == 4)c = a / b;

	return tostring(c);

}

std::string keisan2(std::vector<std::string> &v){

	int res = 0;

	for (int i = 0, j = 0, c = 0; i < v.size(); i++){

		if (v[i] == "("){
			if (c == 0)j = i;
			c++;
		}

		if (v[i] == ")"){
			c--;
			if (c == 0){
				std::vector<std::string>w;
				for (int p = j + 1; p < i; p++)w.push_back(v[p]);
				v[j] = keisan2(w);
				for (int p = j + 1; p <= i; p++)v[p] = "T";
			}
		}
	}


	for (int i = 0; i < v.size(); i++){
		if (v[i] == "*"){
			v[i - 1] = keisan(find(v, i, 1), find(v, i, 0), 3);
			v[i] = v[i + 1] = "T";
		}
		if (v[i] == "/"){
			v[i - 1] = keisan(find(v, i, 1), find(v, i, 0), 4);
			v[i] = v[i + 1] = "T";
		}
	}

	for (int i = 0; i < v.size(); i++){
		if (v[i] == "+"){
			v[i - 1] = keisan(find(v, i, 1), find(v, i, 0), 1);
			v[i] = v[i + 1] = "T";
		}

		if (v[i] == "-"){
			v[i - 1] = keisan(find(v, i, 1), find(v, i, 0), 2);
			v[i] = v[i + 1] = "T";
		}
	}

	v[v.size() - 1] = "T";
	for (int i = 0; i < v.size(); i++){
		if (v[i] != "T")res = toint(v[i]);
	}
	return tostring(res);

}


int main(){

	int n;
	std::cin >> n;

	for (int i = 0; i < n; i++){

		std::string str;

		std::cin >> str;

		std::vector<std::string> v;

		for (int i = 0, j = 0; i < str.size(); i++){

			if (!(str[i] >= '0'&&str[i] <= '9')){
				if (i - j > 0)v.push_back(str.substr(j, i - j));
				v.push_back(str.substr(i, 1));
				j = i + 1;
			}
		}

		std::cout << keisan2(v) << std::endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e17;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14


int expr(const char **);
int term(const char **);
int factor(const char **);
int number(const char **);

int expr(const char **p) {
  int val = term(p);
  while (1) {
    if (**p == '+') {
      (*p)++;
      val += term(p);
    } else if (**p == '-') {
      (*p)++;
      val -= term(p);
    } else {
      break;
    }
  }
  return val;
}

int term(const char **p) {
  int val = factor(p);
  while (1) {
    if (**p == '*') {
      (*p)++;
      val *= factor(p);
    } else if (**p == '/') {
      (*p)++;
      val /= factor(p);
    } else {
      break;
    }
  }
  return val;
}

int factor(const char **p) {
  if (**p == '(') {
    (*p)++;
    int val = expr(p);
    (*p)++;
    return val;
  }
  return number(p);
}

int number(const char **p) {
  int val = 0;
  while ('0' <= **p && **p <= '9') {
    val = val * 10 + **p - '0';
    (*p)++;
  }
  return val;
}

int main() {
  int n;
  scanf("%d", &n);
  char s[101];
  while (n--) {
    scanf("%s", s);
    const char *p = s;
    printf("%d\n", expr(&p));
  }
}